diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..62652db
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+.classpath
+.project
+.settings/
+target/
+logs/
+*.log
+*.iml
+*.ipr
+*.iws
+.idea/
+.DS_Store
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index de05322..c5915db 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -26,7 +26,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_30.xml b/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_30.xml
deleted file mode 100644
index 48ab9df..0000000
--- a/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_30.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index d6343db..0dec81a 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -23,7 +23,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 89e6975..9d93d37 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,22 +1,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -38,67 +23,92 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -109,6 +119,7 @@
@@ -123,17 +134,57 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -155,9 +206,9 @@
-
-
-
+
+
+
@@ -170,7 +221,7 @@
-
+
@@ -183,30 +234,30 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -234,6 +285,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -696,16 +799,25 @@
-
+
+
+
-
-
+
+
+
+
+
+
+
+
+
@@ -723,73 +835,92 @@
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
+
+
+
+
-
-
-
+
+
+
+
+
+
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
+
+
@@ -797,35 +928,35 @@
-
-
-
+
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -841,7 +972,35 @@
-
+
+
+ jar://$MAVEN_REPOSITORY$/mysql/mysql-connector-java/5.1.30/mysql-connector-java-5.1.30-sources.jar!/com/mysql/jdbc/Driver.java
+
+
+
+
+ file://$PROJECT_DIR$/src/test/java/com/ning/test/TransactionTest.java
+ 22
+
+
+
+
+ file://$PROJECT_DIR$/src/main/java/com/ning/serviceimpl/RedisService.java
+ 107
+
+
+
+
+ file://$PROJECT_DIR$/src/main/java/com/ning/serviceimpl/RedisService.java
+ 108
+
+
+
+
+
+
+
+
@@ -850,411 +1009,374 @@
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
+
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
-
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
+
-
+
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
+
-
+
-
-
+
+
@@ -1313,7 +1435,7 @@
- Web|CounterWebApp
+ Spring|CounterWebApp
diff --git a/CounterWebApp.iml b/CounterWebApp.iml
index 4f8cedd..7cc1d3d 100644
--- a/CounterWebApp.iml
+++ b/CounterWebApp.iml
@@ -15,27 +15,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -110,7 +89,7 @@
-
+
@@ -121,5 +100,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/generatorConfig.xml b/generatorConfig.xml
index a640ce5..c142a92 100644
--- a/generatorConfig.xml
+++ b/generatorConfig.xml
@@ -12,7 +12,7 @@
-
+
@@ -32,6 +32,6 @@
-
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c00b52e..718f6d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -266,7 +266,7 @@
fastjson
1.2.7
-
+
com.xiaomi.platform
xmybatis
@@ -315,8 +315,22 @@
-
+
+ edu.uci.ics
+ crawler4j
+ 4.2
+
+
+
+ org.jsoup
+ jsoup
+ 1.7.2
+
+
+
+
+
@@ -334,27 +348,42 @@
${jdk.version}
+
-
-
-
-
- org.mortbay.jetty
- maven-jetty-plugin
- 6.1.26
-
-
- 0
-
- /
-
-
+ org.mortbay.jetty
+ jetty-maven-plugin
+ 8.1.16.v20140903
+
+
+ 0
+ shutdown
+ 9966
+
+
+
+ /
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/com/ning/controller/BlogController.java b/src/main/java/com/ning/controller/BlogController.java
index a9c3fad..796c3e7 100644
--- a/src/main/java/com/ning/controller/BlogController.java
+++ b/src/main/java/com/ning/controller/BlogController.java
@@ -1,21 +1,20 @@
package com.ning.controller;
+import com.ning.controller.base.BaseController;
import com.ning.domain.BlogCategory;
import com.ning.domain.BlogContent;
import com.ning.domain.BlogSubtype;
import com.ning.domain.BlogTag;
import com.ning.serviceimpl.BlogServiceImpl;
-import org.apache.shiro.authz.annotation.RequiresRoles;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -29,11 +28,13 @@ public class BlogController extends BaseController {
@Autowired
private BlogServiceImpl blogService;
- private static final String ADDBLOG = "add_blog";
+ private static final Logger logger= LoggerFactory.getLogger(BlogController.class);
+
+
private static final String BLOGTAGSLIST = "blog_tags_list";
private static final String BLOGDETAIL = "blog_detail";
private static final String BLOGSTATISTICS = "blog_statistics";
- private static final String ABOUT = "about";
+
private List tagsList;
@@ -42,16 +43,12 @@ public class BlogController extends BaseController {
private Map map;
private BlogContent blog;
- @RequiresRoles("admin")
- @RequestMapping(value = "/addblog", method = RequestMethod.GET)
- public ModelAndView blogCategoryView() {
- cateList = blogService.getCateList();
- ModelAndView modelAndView = new ModelAndView(ADDBLOG);
- modelAndView.addObject("cateList", cateList);
- modelAndView.addObject("update", false);
- return modelAndView;
- }
+ /**
+ * Blog tag list model and view.
+ *
+ * @return the model and view
+ */
@RequestMapping(value = "/tagslist", method = RequestMethod.GET)
public ModelAndView blogTagList() {
tagsList = blogService.getTagList();
@@ -60,6 +57,11 @@ public ModelAndView blogTagList() {
return modelAndView;
}
+ /**
+ * Blog trend model and view.
+ *
+ * @return the model and view
+ */
@RequestMapping(value = "/blogTrend", method = RequestMethod.GET)
public ModelAndView blogTrend(){
List list = blogService.getBestList();
@@ -75,11 +77,13 @@ public ModelAndView blogTrend(){
return modelAndView;
}
- @RequestMapping(value = "/about", method = RequestMethod.GET)
- public String about() {
- return ABOUT;
- }
+ /**
+ * Gets sublist.
+ *
+ * @param request the request
+ * @param response the response
+ */
@RequestMapping(value = "/getSublist", method = RequestMethod.GET)
public void getSublist(HttpServletRequest request,HttpServletResponse response) {
Integer cateId =Integer.valueOf(request.getParameter("cateId").toString());
@@ -88,35 +92,13 @@ public void getSublist(HttpServletRequest request,HttpServletResponse response)
return;
}
- @RequestMapping(value = "/createblog", method = RequestMethod.POST, headers="Accept=application/json")
- public @ResponseBody Object createBlog(BlogContent blog, HttpServletRequest request, HttpServletResponse response) {
- map = new HashMap();
- if (blog != null) {
- if (blogService.createBlog(blog) > 0) {
- map.put("msg", "成功");
- } else {
- System.out.println("失败");
- map.put("msg", "失败");
- }
- }
- return map;
- }
- @RequestMapping(value = "/deleteblog", method = RequestMethod.POST, headers="Accept=application/json")
- public @ResponseBody Object deteleBlog(BlogContent blog, HttpServletRequest request, HttpServletResponse response) {
- String id =request.getParameter("id");
- map = new HashMap();
- if (blog != null) {
- if (blogService.deleteBlog(Long.valueOf(id)) > 0) {
- System.out.println("成功删除");
- map.put("msg", "成功删除");
- } else {
- System.out.println("失败");
- map.put("msg", "删除失败");
- }
- }
- return map;
- }
+ /**
+ * Blog detail model and view.
+ *
+ * @param request the request
+ * @return the model and view
+ */
@RequestMapping(value = "/blogdetail", method = RequestMethod.GET)
public ModelAndView blogDetail(HttpServletRequest request) {
String id = request.getParameter("id").toString();
@@ -132,63 +114,78 @@ public ModelAndView blogDetail(HttpServletRequest request) {
return mv;
}
- @RequestMapping(value = "/updateBlog", method = RequestMethod.GET)
- public ModelAndView getBlog(HttpServletRequest request) {
- String id = request.getParameter("id").toString();
- if (id != null && (!id.isEmpty())) {
- blog = blogService.getBlogbyId(Long.valueOf(id));
- }
- cateList = blogService.getCateList();
- ModelAndView mv = new ModelAndView(ADDBLOG);
- mv.addObject("blog", blog);
- mv.addObject("cateList", cateList);
- mv.addObject("update", true);
- return mv;
- }
- @RequestMapping(value = "/updateBlog", method = RequestMethod.POST, headers="Accept=application/json")
- public @ResponseBody Object updateBlog(BlogContent blog, HttpServletRequest request, HttpServletResponse response) {
- map = new HashMap();
- if (blog != null) {
- if (blogService.updateBlog(blog) > 0) {
- map.put("msg", "成功");
- } else {
- System.out.println("失败");
- map.put("msg", "失败");
- }
- }
- return map;
- }
+
+ /**
+ * Gets tags list.
+ *
+ * @return the tags list
+ */
public List getTagsList() {
return tagsList;
}
+ /**
+ * Sets tags list.
+ *
+ * @param tagsList the tags list
+ */
public void setTagsList(List tagsList) {
this.tagsList = tagsList;
}
+ /**
+ * Gets cate list.
+ *
+ * @return the cate list
+ */
public List getCateList() {
return cateList;
}
+ /**
+ * Sets cate list.
+ *
+ * @param cateList the cate list
+ */
public void setCateList(List cateList) {
this.cateList = cateList;
}
+ /**
+ * Gets blog.
+ *
+ * @return the blog
+ */
public BlogContent getBlog() {
return blog;
}
+ /**
+ * Sets blog.
+ *
+ * @param blog the blog
+ */
public void setBlog(BlogContent blog) {
this.blog = blog;
}
+ /**
+ * Gets map.
+ *
+ * @return the map
+ */
public Map getMap() {
return map;
}
+ /**
+ * Sets map.
+ *
+ * @param map the map
+ */
public void setMap(Map map) {
this.map = map;
}
diff --git a/src/main/java/com/ning/controller/MainController.java b/src/main/java/com/ning/controller/MainController.java
index b923d5f..57aeeff 100644
--- a/src/main/java/com/ning/controller/MainController.java
+++ b/src/main/java/com/ning/controller/MainController.java
@@ -1,10 +1,15 @@
package com.ning.controller;
+import com.ning.controller.base.BaseController;
+import com.ning.dao.Tool;
import com.ning.domain.BlogContent;
import com.ning.domain.BlogSearchVO;
import com.ning.domain.User;
import com.ning.serviceimpl.BlogServiceImpl;
+import com.ning.serviceimpl.RedisService;
+import com.ning.serviceimpl.ToolService;
+import com.ning.services.IToolService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -16,17 +21,25 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
+import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.security.Principal;
import java.util.*;
+/**
+ * The type Main controller.
+ */
/*There must be a Controller annotation or the application will doesn't work .*/
@Controller
-public class MainController extends BaseController{
+public class MainController extends BaseController {
@Autowired
private BlogServiceImpl blogService;
+ @Autowired
+ private RedisService redisService;
+ @Resource
+ private IToolService toolService;
private static int COUNTER = 0;
private static final String VIEW_INDEX = "index";
@@ -34,12 +47,23 @@ public class MainController extends BaseController{
private static final String ADDVIEW = "add";
private static final String USERLIST = "user_list";
private static final String TEST = "test";
+ private static final String TIME_LINE = "timeline";
+ private static final String ABOUT = "about";
+ private static final String TOOLS = "tools";
+ private static final String PANEL = "panelview";
private static final Logger logger = LoggerFactory.getLogger(MainController.class);
private List userList;
private List blogList;
private List bestVisitBlogList;
+ private List tags;
+ /**
+ * Welcome string.
+ *
+ * @param model the model
+ * @return the string
+ */
@RequestMapping(value = "/dd", method = RequestMethod.GET)
public String welcome(ModelMap model) {
model.addAttribute("message", "Welcome");
@@ -48,6 +72,14 @@ public String welcome(ModelMap model) {
return VIEW_INDEX;//返回index.jsp
}
+ /**
+ * Indexpage model and view.
+ *
+ * @param model the model
+ * @param request the request
+ * @param principal the principal
+ * @return the model and view
+ */
@RequestMapping(value = {"/","/index",}, method = RequestMethod.GET)
public ModelAndView indexpage(ModelMap model,HttpServletRequest request, Principal principal) {
if(principal!=null){
@@ -72,9 +104,16 @@ public ModelAndView indexpage(ModelMap model,HttpServletRequest request, Princip
mv.addObject("blogList",blogList);
mv.addObject("bestBlogList",bestVisitBlogList);
mv.addObject("user",this.getUser());
+ mv.addObject("tagList", redisService.getTags());
return mv;
}
+ /**
+ * Lifepage model and view.
+ *
+ * @param model the model
+ * @return the model and view
+ */
@RequestMapping(value = {"/life",}, method = RequestMethod.GET)
public ModelAndView lifepage(ModelMap model) {
ModelAndView mv=new ModelAndView(LIFE_INDEX);
@@ -93,14 +132,27 @@ public ModelAndView lifepage(ModelMap model) {
mv.addObject("page",page);
mv.addObject("blogList",blogList);
mv.addObject("bestBlogList",bestVisitBlogList);
+ mv.addObject("tagList", redisService.getTags());
return mv;
}
+
+ /**
+ * Addview string.
+ *
+ * @return the string
+ */
@RequestMapping(value = "/addview",method = RequestMethod.GET)
public String addview(){
return ADDVIEW;
}
+ /**
+ * Add model and view.
+ *
+ * @param request the request
+ * @return the model and view
+ */
@RequestMapping(value = "/adduser",method = RequestMethod.POST)
public ModelAndView add(HttpServletRequest request){
@@ -110,18 +162,88 @@ public ModelAndView add(HttpServletRequest request){
return mav;
}
+ /**
+ * Userlist string.
+ *
+ * @param model the model
+ * @return the string
+ */
@RequestMapping(value = "/user_list",method = RequestMethod.GET)
public String userlist(Model model){
return USERLIST;
}
+ /**
+ * Test string.
+ *
+ * @param model the model
+ * @return the string
+ */
@RequestMapping(value = "/test",method = RequestMethod.GET)
public String test(Model model){
return TEST;
}
+ /**
+ * Time line model and view.
+ *
+ * @param request the request
+ * @return the model and view
+ */
+ @RequestMapping(value = "/timeline",method = RequestMethod.GET)
+ public ModelAndView timeLine(HttpServletRequest request){
+ String tag=request.getParameter("tag")==null?"":request.getParameter("tag");
+ ModelAndView mv=new ModelAndView(TIME_LINE);
+ BlogSearchVO searchVO=new BlogSearchVO();
+ if(tag.length()>0){
+ searchVO.setTag(tag);
+ }
+ blogList=blogService.getBlogList(page,searchVO);
+ blogList=blogService.getFixBlogList(blogList);
+ if (blogList != null && blogList.size() > 0) {
+ this.setDisplayPageBar(true);
+ } else {
+ blogList = null;
+ this.setDisplayPageBar(false);
+ }
+ mv.addObject("blogList",blogList);
+ return mv ;
+ }
+
+ /**
+ * About model and view.
+ *
+ * @return the model and view
+ */
+ @RequestMapping(value = "/about", method = RequestMethod.GET)
+ public ModelAndView about() {
+ ModelAndView mv=new ModelAndView(ABOUT);
+ return mv;
+ }
+
+ /**
+ * Tool model and view.
+ *
+ * @return the model and view
+ */
+ @RequestMapping(value = "/tools", method = RequestMethod.GET)
+ public ModelAndView tool() {
+ Tool tool=new Tool();
+ List toolList= toolService.getToolsbyPage(page,tool);
+ ModelAndView mv=new ModelAndView(TOOLS);
+ mv.addObject("toolList",toolList);
+ return mv;
+ }
+
+
+ @RequestMapping(value = "/panel", method = RequestMethod.GET)
+ public ModelAndView panel() {
+ ModelAndView mv=new ModelAndView(PANEL);
+ return mv;
+ }
+
/***
* 验证参数是否为空
* @param params
diff --git a/src/main/java/com/ning/controller/ManageController.java b/src/main/java/com/ning/controller/ManageController.java
index c9df2bd..1e60ff2 100644
--- a/src/main/java/com/ning/controller/ManageController.java
+++ b/src/main/java/com/ning/controller/ManageController.java
@@ -1,23 +1,33 @@
package com.ning.controller;
import com.alibaba.druid.util.StringUtils;
-import com.ning.domain.BlogContent;
-import com.ning.domain.BlogSearchVO;
-import com.ning.domain.User;
+import com.ning.controller.base.BaseController;
+import com.ning.dao.HouseRecord;
+import com.ning.dao.Tool;
+import com.ning.domain.*;
import com.ning.serviceimpl.BlogServiceImpl;
import com.ning.serviceimpl.ManageService;
+import com.ning.serviceimpl.RedisService;
+import com.ning.services.ILjService;
+import com.ning.services.IToolService;
import com.ning.utils.CommonUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authz.annotation.RequiresRoles;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
+import javax.annotation.Resource;
+import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
@@ -28,33 +38,76 @@
* Created by ning on 10/23/15.
*/
@Controller
-public class ManageController extends BaseController{
+public class ManageController extends BaseController {
+ private static final Logger logger= LoggerFactory.getLogger(ManageController.class);
+
+ @Autowired
+ private BlogServiceImpl blogService;
+ @Autowired
+ private ManageService manageService;
+ @Resource
+ private IToolService toolService;
+ @Resource
+ private RedisService redisService;
+
+ @Resource
+ private ILjService ljService;
+
private static final String PAGE_MANAGE="manage";
private static final String LOGIN="login";
private static final String UNAUTHORIZED="unauthorized";
private static final String BLOGMANAGE="blog_manage";
+ private static final String TOOLMANAGE="manage/tool_manage";
+ private static final String TITLEMANAGE="manage/title_manage";
private static final String LOGOUT="logoutsucc";
private static final String ADDUSER="add_user";
+ private static final String ADDSUBTITLE="manage/add_title";
+ private static final String REDISMANAGE="manage/redis_manage";
+ private static final String ADDTOOL="manage/add_tool";
+ private static final String ADDBLOG = "add_blog";
- @Autowired
- private BlogServiceImpl blogService;
- @Autowired
- private ManageService manageService;
+ private static final String LJManage="manage/lianjia_manage";
+ private Map map;
+ private BlogContent blog;
+ private Tool tool;
+ private HouseRecord houseRecord;
+ private BlogSubtype type;
+ private List cateList;
+
+ /**
+ * Base string.
+ *
+ * @param model the model
+ * @return the string
+ */
@RequiresRoles("admin")
- @RequestMapping(value = "manage",method= RequestMethod.GET)
+ @RequestMapping(value = "/manage",method= RequestMethod.GET)
public String base(Model model){
return PAGE_MANAGE;
}
+
+ /**
+ * Show login page string.
+ *
+ * @return the string
+ */
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String showLoginPage() {
return "login";
}
+ /**
+ * Submit login form string.
+ *
+ * @param request the request
+ * @param model the model
+ * @return the string
+ */
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String submitLoginForm(HttpServletRequest request, Model model) {
@@ -71,17 +124,36 @@ public String submitLoginForm(HttpServletRequest request, Model model) {
return "login";
}
+ /**
+ * Logout string.
+ *
+ * @param model the model
+ * @return the string
+ */
@RequestMapping(value = "/logoutsucc",method= RequestMethod.GET)
public String logout(Model model){
return "redirect:/index";
}
+ /**
+ * Unauthorized string.
+ *
+ * @param model the model
+ * @return the string
+ */
@RequestMapping(value = "/unauthorized",method= RequestMethod.GET)
public String unauthorized(Model model){
return UNAUTHORIZED;
}
- @RequestMapping(value = "blogManage",method= RequestMethod.POST)
+ /**
+ * Blog manage model and view.
+ *
+ * @param blogseach the blogseach
+ * @return the model and view
+ */
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/blogManage",method= {RequestMethod.GET, RequestMethod.POST })
public ModelAndView blogManage(String blogseach){
ModelAndView mv=new ModelAndView(BLOGMANAGE);
BlogSearchVO searchVO=new BlogSearchVO();
@@ -110,41 +182,304 @@ public ModelAndView blogManage(String blogseach){
return mv;
}
- @RequestMapping(value = "blogManage",method= RequestMethod.GET)
- public ModelAndView getBlogManage(String blogseach){
- ModelAndView mv=new ModelAndView(BLOGMANAGE);
- BlogSearchVO searchVO=new BlogSearchVO();
- List blogList=null;
- if(!StringUtils.isEmpty(blogseach)){
- if(CommonUtils.isNumeric(blogseach)){
- searchVO.setId(Long.valueOf(blogseach));
- }else{
- searchVO.setTitle(blogseach);
+
+ /**
+ * Blog category view model and view.
+ *
+ * @return the model and view
+ */
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/addblog", method = RequestMethod.GET)
+ public ModelAndView blogCategoryView() {
+ cateList = blogService.getCateList();
+ ModelAndView modelAndView = new ModelAndView(ADDBLOG);
+ modelAndView.addObject("cateList", cateList);
+ modelAndView.addObject("update", false);
+ return modelAndView;
+ }
+
+
+ /**
+ * Create blog string.
+ * ajax 方式提交blog
+ * @param blog the blog
+ * @param request the request
+ * @param response the response
+ * @return the string
+ */
+ @RequestMapping(value = "/createblog", method = RequestMethod.POST, headers="Accept=application/json")
+ public @ResponseBody Object createBlog(BlogContent blog, HttpServletRequest request, HttpServletResponse response) {
+ map = new HashMap();
+ System.out.println(blog.getBlogTitle());
+ System.out.println(blog.getTags());
+ if (blog != null) {
+ if (blogService.createBlog(blog) > 0) {
+ logger.debug("add blog success!");
+ map.put("msg", "成功");
+ } else {
+ logger.debug("add blog fail!");
+ map.put("msg", "失败");
}
- blogList=blogService.getBlogList(page,searchVO);
- }else{
- blogList=blogService.getBlogList(page,searchVO);
}
+ return map;
+ }
- if (blogList != null && blogList.size() > 0) {
+ /**
+ * Post object model and view.
+ * 表单提交
+ * @param blog the blog
+ * @param request the request
+ * @param response the response
+ * @return the model and view
+ */
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/postblog", method = RequestMethod.POST)
+ public ModelAndView postObject(@ModelAttribute("blog")BlogContent blog, HttpServletRequest request, HttpServletResponse response) {
+ System.out.println(blog.getBlogTitle());
+ System.out.println(blog.getTags());
+ ModelAndView mv =new ModelAndView(ADDBLOG);
+ if (blog != null) {
+ if (blogService.createBlog(blog) > 0) {
+ logger.debug("add blog success!");
+ } else {
+ logger.debug("add blog fail!");
+ }
+ }
+ return mv;
+ }
+
+
+ /**
+ * Detele blog object.
+ *
+ * @param blog the blog
+ * @param request the request
+ * @param response the response
+ * @return the object
+ */
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/deleteblog", method = RequestMethod.POST, headers="Accept=application/json")
+ public @ResponseBody Object deteleBlog(BlogContent blog, HttpServletRequest request, HttpServletResponse response) {
+ String id =request.getParameter("id");
+ map = new HashMap();
+ if (blog != null) {
+ if (blogService.deleteBlog(Long.valueOf(id)) > 0) {
+ System.out.println("成功删除");
+ map.put("msg", "成功删除");
+ } else {
+ System.out.println("失败");
+ map.put("msg", "删除失败");
+ }
+ }
+ return map;
+ }
+
+
+ /**
+ * Gets blog.
+ *
+ * @param request the request
+ * @return the blog
+ */
+ @RequestMapping(value = "/updateBlog", method = RequestMethod.GET)
+ public ModelAndView getBlog(HttpServletRequest request) {
+ String id = request.getParameter("id").toString();
+ if (id != null && (!id.isEmpty())) {
+ blog = blogService.getBlogbyId(Long.valueOf(id));
+ }
+ cateList = blogService.getCateList();
+ ModelAndView mv = new ModelAndView(ADDBLOG);
+ mv.addObject("blog", blog);
+ mv.addObject("cateList", cateList);
+ mv.addObject("update", true);
+ return mv;
+ }
+
+ /**
+ * Update blog object.
+ *
+ * @param blog the blog
+ * @param request the request
+ * @param response the response
+ * @return the object
+ */
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/updateBlog", method = RequestMethod.POST, headers="Accept=application/json")
+ public @ResponseBody Object updateBlog(BlogContent blog, HttpServletRequest request, HttpServletResponse response) {
+ map = new HashMap();
+ if (blog != null) {
+ if (blogService.updateBlog(blog) > 0) {
+ map.put("msg", "成功");
+ } else {
+ System.out.println("失败");
+ map.put("msg", "失败");
+ }
+ }
+ return map;
+ }
+
+
+ /**
+ * Get blog manage model and view.
+ *
+ * @return the model and view
+ */
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/toolManage",method= {RequestMethod.GET, RequestMethod.POST })
+ public ModelAndView getBlogManage(String toolsearch){
+ ModelAndView mv=new ModelAndView(TOOLMANAGE);
+ Tool tool=new Tool();
+ if(!StringUtils.isEmpty(toolsearch)) {
+ if (CommonUtils.isNumeric(toolsearch)) {
+ tool.setId(Integer.valueOf(toolsearch));
+ } else {
+ tool.setToolName(toolsearch);
+ }
+ }
+
+ List toolList= toolService.getToolsbyPage(page,tool);
+
+ if (toolList != null && toolList.size() > 0) {
this.setDisplayPageBar(true);
} else {
- blogList = null;
+ toolList = null;
this.setDisplayPageBar(false);
}
+
mv.addObject("displayPageBar",displayPageBar);
mv.addObject("page",page);
- mv.addObject("blogList",blogList);
- mv.addObject("blogseach",blogseach);
+ mv.addObject("toolList",toolList);
+ mv.addObject("toolsearch",toolsearch);
+ return mv;
+ }
+
+ /**
+ * Get blog manage model and view.
+ *
+ * @return the model and view
+ */
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/lianjiaManage",method= {RequestMethod.GET, RequestMethod.POST })
+ public ModelAndView getLJManage(String toolsearch){
+ ModelAndView mv=new ModelAndView(LJManage);
+ HouseRecord houseRecord=new HouseRecord();
+ if(!StringUtils.isEmpty(toolsearch)) {
+ if (CommonUtils.isNumeric(toolsearch)) {
+ houseRecord.setId(Integer.valueOf(toolsearch));
+ } else {
+ houseRecord.setTitle(toolsearch);
+ }
+ }
+
+ List houseList= ljService.getHouseRecordListByPage(page,houseRecord);
+
+ if (houseList != null && houseList.size() > 0) {
+ this.setDisplayPageBar(true);
+ } else {
+ houseList = null;
+ this.setDisplayPageBar(false);
+ }
+
+ mv.addObject("displayPageBar",displayPageBar);
+ mv.addObject("page",page);
+ mv.addObject("houseList",houseList);
+ mv.addObject("toolsearch",toolsearch);
return mv;
}
- @RequestMapping(value = "addUser",method= RequestMethod.GET)
+
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/addTool", method = RequestMethod.GET)
+ public ModelAndView addTool() {
+ ModelAndView modelAndView = new ModelAndView(ADDTOOL);
+ return modelAndView;
+ }
+
+
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/postTool", method = RequestMethod.POST)
+ public String postObject(@ModelAttribute("tool")Tool tool, HttpServletRequest request, HttpServletResponse response) {
+ System.out.println(tool.getToolName());
+ System.out.println(tool.getType());
+ if (tool != null) {
+ try{
+ toolService.insertTool(tool,"Oliver");
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+ return "redirect:/toolManage";
+ }
+
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/deleteTool", method = RequestMethod.POST, headers="Accept=application/json")
+ public @ResponseBody Object deteleTool(Tool tool, HttpServletRequest request, HttpServletResponse response) {
+ String id =request.getParameter("id");
+ map = new HashMap();
+ if (tool != null) {
+ if(toolService.deleteTool(Integer.valueOf(id))>0) {
+ System.out.println("成功删除");
+ map.put("msg", "成功删除");
+ } else {
+ System.out.println("失败");
+ map.put("msg", "删除失败");
+ }
+ }
+ return map;
+ }
+
+
+ @RequestMapping(value = "/updateTool", method = RequestMethod.GET)
+ public ModelAndView getTool(HttpServletRequest request) {
+ String id = request.getParameter("id").toString();
+ if (id != null && (!id.isEmpty())) {
+ tool = toolService.getTool(Integer.valueOf(id));
+ }
+ cateList = blogService.getCateList();
+ ModelAndView mv = new ModelAndView(ADDTOOL);
+ mv.addObject("tool", tool);
+ mv.addObject("update", true);
+ return mv;
+ }
+
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/updateTool", method = RequestMethod.POST, headers="Accept=application/json")
+ public @ResponseBody Object updateTool(Tool tool, HttpServletRequest request, HttpServletResponse response) {
+ map = new HashMap();
+ if (blog != null) {
+ if (toolService.updateTool(tool)> 0) {
+ map.put("msg", "成功");
+ } else {
+ System.out.println("失败");
+ map.put("msg", "失败");
+ }
+ }
+ return map;
+ }
+
+
+
+ /**
+ * Add user string.
+ *
+ * @return the string
+ */
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/addUser",method= RequestMethod.GET)
public String addUser(){
return ADDUSER;
}
- @RequestMapping(value = "createUser",method= RequestMethod.POST, headers="Accept=application/json")
+ /**
+ * Create user object.
+ *
+ * @param user the user
+ * @param request the request
+ * @param response the response
+ * @return the object
+ */
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/createUser",method= RequestMethod.POST, headers="Accept=application/json")
public @ResponseBody Object createUser(User user, HttpServletRequest request, HttpServletResponse response) {
Map map = new HashMap();
if (user != null) {
@@ -158,4 +493,101 @@ public String addUser(){
}
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/subTitleManage",method= {RequestMethod.GET, RequestMethod.POST })
+ public ModelAndView subTitleManage(String search){
+ ModelAndView mv=new ModelAndView(TITLEMANAGE);
+ BlogSubtype subtype =new BlogSubtype();
+ if(!StringUtils.isEmpty(search)) {
+ if (CommonUtils.isNumeric(search)) {
+ subtype.setId(Short.valueOf(search));
+ } else {
+ subtype.setSubTitle(search);
+ }
+ }
+
+ List typeList=blogService.getSubtypeListbyPage(page,subtype);
+
+ if (typeList != null && typeList.size() > 0) {
+ this.setDisplayPageBar(true);
+ } else {
+ typeList = null;
+ this.setDisplayPageBar(false);
+ }
+
+ mv.addObject("displayPageBar",displayPageBar);
+ mv.addObject("page",page);
+ mv.addObject("typeList",typeList);
+ mv.addObject("search",search);
+ return mv;
+ }
+
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/addSubtitle",method= RequestMethod.GET)
+ public String getSubTitlePage(){
+ return ADDSUBTITLE;
+ }
+
+
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/postSubtitle", method = RequestMethod.POST)
+ public String postObject(@ModelAttribute("subTitle")BlogSubtype subTitle, HttpServletRequest request, HttpServletResponse response) {
+ if (subTitle != null) {
+ try{
+ toolService.insertSubType(subTitle,"Oliver");
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+ return "redirect:/subTitleManage";
+ }
+
+
+
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/deleteType", method = RequestMethod.POST, headers="Accept=application/json")
+ public @ResponseBody Object deleteType(Tool tool, HttpServletRequest request, HttpServletResponse response) {
+ String id =request.getParameter("id");
+ map = new HashMap();
+ if (tool != null) {
+ if(toolService.deleteSubType(Short.valueOf(id))>0) {
+ System.out.println("成功删除");
+ map.put("msg", "成功删除");
+ } else {
+ System.out.println("失败");
+ map.put("msg", "删除失败");
+ }
+ }
+ return map;
+ }
+
+
+ @RequestMapping(value = "/updateType", method = RequestMethod.GET)
+ public ModelAndView updateType(HttpServletRequest request) {
+ String id = request.getParameter("id").toString();
+ if (id != null && (!id.isEmpty())) {
+ type = blogService.getSubtype(Short.valueOf(id));
+ }
+ ModelAndView mv = new ModelAndView(ADDSUBTITLE);
+ mv.addObject("type", type);
+ mv.addObject("update", true);
+ return mv;
+ }
+
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/redisManage",method= RequestMethod.GET)
+ public ModelAndView redisManage(){
+ ModelAndView mv = new ModelAndView(REDISMANAGE);
+ return mv;
+ }
+
+ @RequiresRoles("admin")
+ @RequestMapping(value = "/cleanTags", method = RequestMethod.GET)
+ public String cleanTags(HttpServletRequest request, HttpServletResponse response) {
+ redisService.cleanTags();
+ return "redirect:/redisManage";
+ }
+
+
+
}
diff --git a/src/main/java/com/ning/controller/TestController.java b/src/main/java/com/ning/controller/TestController.java
index ae3401e..2e3d30d 100644
--- a/src/main/java/com/ning/controller/TestController.java
+++ b/src/main/java/com/ning/controller/TestController.java
@@ -2,6 +2,7 @@
import com.ning.domain.BlogContent;
import com.ning.serviceimpl.RedisService;
+import com.ning.services.ICrawlerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -25,14 +26,24 @@ public class TestController {
private static final String TEST = "test";
private static final String ECHARTEST = "echars_test";
private static final String REDIS = "redis_test";
+ private static final String TIMELINE = "view_timeline";
@Autowired
private RedisService redisService;
+ @Autowired
+ private ICrawlerService crawlerService;
+
private Map map;
@RequestMapping(value = "/testbs", method = RequestMethod.GET)
public String testPage() {
+ try {
+ crawlerService.crawling();
+// Thread.sleep(10000);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return TEST;
}
@@ -84,4 +95,30 @@ public ModelAndView getAllHash(HttpServletRequest request) {
return modelAndView;
}
+
+ @RequestMapping(value = "/append", method = RequestMethod.GET)
+ public String StringAppend(HttpServletRequest request, HttpServletResponse response) {
+ String key = request.getParameter("key").trim().toString();
+ String value = request.getParameter("value").trim().toString();
+ redisService.append(key, value);
+ return REDIS;
+ }
+
+
+ @RequestMapping(value = "/getstr", method = RequestMethod.GET)
+ public ModelAndView getString(HttpServletRequest request) {
+ ModelAndView modelAndView = new ModelAndView(REDIS);
+ String key = request.getParameter("key").trim().toString();
+ String value = redisService.getString(key);
+ modelAndView.addObject("string", value);
+ return modelAndView;
+ }
+
+ @RequestMapping(value = "/time", method = RequestMethod.GET)
+ public ModelAndView timeline(HttpServletRequest request) {
+ ModelAndView modelAndView = new ModelAndView(TIMELINE);
+ return modelAndView;
+ }
+
+
}
diff --git a/src/main/java/com/ning/controller/BaseController.java b/src/main/java/com/ning/controller/base/BaseController.java
similarity index 99%
rename from src/main/java/com/ning/controller/BaseController.java
rename to src/main/java/com/ning/controller/base/BaseController.java
index 1351b82..353b5d5 100644
--- a/src/main/java/com/ning/controller/BaseController.java
+++ b/src/main/java/com/ning/controller/base/BaseController.java
@@ -1,4 +1,4 @@
-package com.ning.controller;
+package com.ning.controller.base;
import com.ning.domain.BasicConstants;
import com.ning.domain.User;
diff --git a/src/main/java/com/ning/crawler/Controller.java b/src/main/java/com/ning/crawler/Controller.java
new file mode 100644
index 0000000..48dcd1d
--- /dev/null
+++ b/src/main/java/com/ning/crawler/Controller.java
@@ -0,0 +1,45 @@
+package com.ning.crawler;
+
+import edu.uci.ics.crawler4j.crawler.CrawlConfig;
+import edu.uci.ics.crawler4j.crawler.CrawlController;
+import edu.uci.ics.crawler4j.fetcher.PageFetcher;
+import edu.uci.ics.crawler4j.robotstxt.RobotstxtConfig;
+import edu.uci.ics.crawler4j.robotstxt.RobotstxtServer;
+
+/**
+ * Created by oliver on 2017/2/16.
+ */
+public class Controller {
+
+ public static void main(String[] args) throws Exception {
+ String crawlStorageFolder = "/Users/oliver/test/crawler";
+ int numberOfCrawlers = 1;
+
+ CrawlConfig config = new CrawlConfig();
+ config.setCrawlStorageFolder(crawlStorageFolder);
+
+ /*
+ * Instantiate the controller for this crawl.
+ */
+ PageFetcher pageFetcher = new PageFetcher(config);
+ RobotstxtConfig robotstxtConfig = new RobotstxtConfig();
+ robotstxtConfig.setEnabled(false);
+ RobotstxtServer robotsServer = new RobotstxtServer(robotstxtConfig, pageFetcher);
+ CrawlController controller = new CrawlController(config, pageFetcher, robotsServer);
+
+ /*
+ * For each crawl, you need to add some seed urls. These are the first
+ * URLs that are fetched and then the crawler starts following links
+ * which are found in these pages
+ */
+// controller.addSeed("http://bj.lianjia.com/ershoufang");
+ controller.addSeed("http://yemengying.com/");
+// controller.addSeed("http://bj.lianjia.com/ershoufang/haidian/");
+
+ /*
+ * Start the crawl. This is a blocking operation, meaning that your code
+ * will reach the line after this only when crawling is finished.
+ */
+// controller.start(LjCrawler.class, numberOfCrawlers);
+ }
+}
diff --git a/src/main/java/com/ning/crawler/LjCrawler.java b/src/main/java/com/ning/crawler/LjCrawler.java
new file mode 100644
index 0000000..429c0de
--- /dev/null
+++ b/src/main/java/com/ning/crawler/LjCrawler.java
@@ -0,0 +1,115 @@
+package com.ning.crawler;
+
+import com.ning.dao.HouseRecord;
+import com.ning.domain.BlogCategory;
+import com.ning.mapper.BlogCategoryMapper;
+import com.ning.mapper.HouseRecordMapper;
+import com.ning.utils.SpringBeanFactoryUtils;
+import edu.uci.ics.crawler4j.crawler.Page;
+import edu.uci.ics.crawler4j.crawler.WebCrawler;
+import edu.uci.ics.crawler4j.parser.HtmlParseData;
+import edu.uci.ics.crawler4j.url.WebURL;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.regex.Pattern;
+
+/**
+ * Created by oliver on 2017/2/16.
+ */
+public class LjCrawler extends WebCrawler {
+
+ private static final Logger logger= LoggerFactory.getLogger(LjCrawler.class);
+
+ private final static Pattern FILTERS = Pattern.compile(".*(\\.(css|js|gif|jpg"
+ + "|png|mp3|mp3|zip|gz))$");
+
+ @Autowired
+ private BlogCategoryMapper blogCategoryMapper;
+
+ private HouseRecordMapper houseRecordMapper;
+
+ public LjCrawler() {
+ houseRecordMapper =SpringBeanFactoryUtils.getApplicationContext().getBean(HouseRecordMapper.class);
+ }
+
+ @Override
+ public boolean shouldVisit(Page referringPage, WebURL url) {
+ String href = url.getURL().toLowerCase();
+ return !FILTERS.matcher(href).matches()
+ && href.startsWith("http://qd.lianjia.com");
+ }
+
+ @Override
+ public void visit(Page page) {
+ String url = page.getWebURL().getURL();
+ logger.info("URL: " + url);
+ if (page.getParseData() instanceof HtmlParseData) {
+ HtmlParseData htmlParseData = (HtmlParseData) page.getParseData();
+ String html = htmlParseData.getHtml();
+ Document document= Jsoup.parse(html);
+ Elements elements= document.body().getElementsByClass("sellListContent");
+ for(Element e:elements){
+ HouseRecord record=new HouseRecord();
+ Elements info= e.getElementsByClass("clear").get(1).getAllElements();
+ System.out.println("--------------------------------------");
+ for(Element infoItem:info){
+
+ switch (infoItem.className()){
+ case "title":
+ System.out.println("title:"+infoItem.getElementsByClass("title").get(0).text());
+ record.setTitle(infoItem.getElementsByClass("title").get(0).text());
+ break;
+ case "address":
+ System.out.println("address:"+infoItem.getElementsByClass("houseInfo").last().text());
+ record.setAddress(infoItem.getElementsByClass("houseInfo").last().text());
+ break;
+ case "flood":
+ String desc=infoItem.getElementsByClass("flood").first().child(0).ownText();
+ System.out.println("desc:"+infoItem.getElementsByClass("flood").first().child(0).ownText());
+ String area=infoItem.getElementsByClass("flood").first().child(0).child(1).text();
+ System.out.println("area:"+infoItem.getElementsByClass("flood").first().child(0).child(1).text());
+ record.setDescri(desc);
+ record.setArea(area);
+ break;
+ case "followInfo":
+ System.out.println("followInfo:"+infoItem.getElementsByClass("followInfo").text());
+ record.setFollowInfo(infoItem.getElementsByClass("followInfo").text());
+ break;
+ case "tag":
+ System.out.println("tag:"+infoItem.getElementsByClass("tag").text());
+ record.setDescri(infoItem.getElementsByClass("tag").text());
+ break;
+ case "priceInfo":
+ Elements price=infoItem.getElementsByClass("priceInfo");
+ String totlePrice=price.get(0).child(0).text().replaceAll("\\D+","");
+ record.setPrice(new BigDecimal(totlePrice));
+ System.out.println("priceInfo:"+totlePrice);
+ String unitPrice=price.get(0).child(1).text().replaceAll("\\D+","");
+ System.out.println("unitPrice:"+price.get(0).child(1).text().replaceAll("\\D+",""));
+ record.setUnitPrice(new BigDecimal(unitPrice));
+ break;
+ default:
+ break;
+ }
+ }
+ record.setCreateTime(new Date());
+ record.setCreatePerson("Machine");
+ if(houseRecordMapper.countByTitle(record.getTitle())==0){
+ houseRecordMapper.insert(record);
+ logger.info("insert one record ");
+ }else{
+ logger.info("insert no record ");
+ }
+
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/ning/crawler/MyCrawler.java b/src/main/java/com/ning/crawler/MyCrawler.java
new file mode 100644
index 0000000..2b7a938
--- /dev/null
+++ b/src/main/java/com/ning/crawler/MyCrawler.java
@@ -0,0 +1,55 @@
+package com.ning.crawler;
+
+import edu.uci.ics.crawler4j.crawler.Page;
+import edu.uci.ics.crawler4j.crawler.WebCrawler;
+import edu.uci.ics.crawler4j.parser.HtmlParseData;
+import edu.uci.ics.crawler4j.url.WebURL;
+
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * Created by oliver on 2017/2/16.
+ */
+public class MyCrawler extends WebCrawler {
+ private final static Pattern FILTERS = Pattern.compile(".*(\\.(css|js|gif|jpg"
+ + "|png|mp3|mp3|zip|gz))$");
+
+ /**
+ * This method receives two parameters. The first parameter is the page
+ * in which we have discovered this new url and the second parameter is
+ * the new url. You should implement this function to specify whether
+ * the given url should be crawled or not (based on your crawling logic).
+ * In this example, we are instructing the crawler to ignore urls that
+ * have css, js, git, ... extensions and to only accept urls that start
+ * with "http://www.ics.uci.edu/". In this case, we didn't need the
+ * referringPage parameter to make the decision.
+ */
+ @Override
+ public boolean shouldVisit(Page referringPage, WebURL url) {
+ String href = url.getURL().toLowerCase();
+ return !FILTERS.matcher(href).matches()
+ && href.startsWith("http://yemengying.com");
+ }
+
+ /**
+ * This function is called when a page is fetched and ready
+ * to be processed by your program.
+ */
+ @Override
+ public void visit(Page page) {
+ String url = page.getWebURL().getURL();
+ System.out.println("URL: " + url);
+
+ if (page.getParseData() instanceof HtmlParseData) {
+ HtmlParseData htmlParseData = (HtmlParseData) page.getParseData();
+ String text = htmlParseData.getText();
+ String html = htmlParseData.getHtml();
+ Set links = htmlParseData.getOutgoingUrls();
+
+ System.out.println("Text length: " + text.length());
+ System.out.println("Html length: " + html.length());
+ System.out.println("Number of outgoing links: " + links.size());
+ }
+ }
+}
diff --git a/src/main/java/com/ning/dao/HouseRecord.java b/src/main/java/com/ning/dao/HouseRecord.java
new file mode 100644
index 0000000..a42a80d
--- /dev/null
+++ b/src/main/java/com/ning/dao/HouseRecord.java
@@ -0,0 +1,106 @@
+package com.ning.dao;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+public class HouseRecord {
+ private Integer id;
+
+ private String title;
+
+ private String address;
+
+ private String descri;
+
+ private String area;
+
+ private String followInfo;
+
+ private BigDecimal price;
+
+ private BigDecimal unitPrice;
+
+ private Date createTime;
+
+ private String createPerson;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title == null ? null : title.trim();
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address == null ? null : address.trim();
+ }
+
+ public String getDescri() {
+ return descri;
+ }
+
+ public void setDescri(String descri) {
+ this.descri = descri == null ? null : descri.trim();
+ }
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area == null ? null : area.trim();
+ }
+
+ public String getFollowInfo() {
+ return followInfo;
+ }
+
+ public void setFollowInfo(String followInfo) {
+ this.followInfo = followInfo == null ? null : followInfo.trim();
+ }
+
+ public BigDecimal getPrice() {
+ return price;
+ }
+
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+
+ public BigDecimal getUnitPrice() {
+ return unitPrice;
+ }
+
+ public void setUnitPrice(BigDecimal unitPrice) {
+ this.unitPrice = unitPrice;
+ }
+
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+
+ public String getCreatePerson() {
+ return createPerson;
+ }
+
+ public void setCreatePerson(String createPerson) {
+ this.createPerson = createPerson == null ? null : createPerson.trim();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ning/dao/Tool.java b/src/main/java/com/ning/dao/Tool.java
new file mode 100644
index 0000000..5ac7bb3
--- /dev/null
+++ b/src/main/java/com/ning/dao/Tool.java
@@ -0,0 +1,288 @@
+package com.ning.dao;
+
+import java.util.Date;
+
+public class Tool {
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column tools.id
+ *
+ * @mbggenerated
+ */
+ private Integer id;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column tools.type
+ *
+ * @mbggenerated
+ */
+ private String type;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column tools.tool_name
+ *
+ * @mbggenerated
+ */
+ private String toolName;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column tools.tool_icon
+ *
+ * @mbggenerated
+ */
+ private String toolIcon;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column tools.tool_url
+ *
+ * @mbggenerated
+ */
+ private String toolUrl;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column tools.create_time
+ *
+ * @mbggenerated
+ */
+ private Date createTime;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column tools.update_time
+ *
+ * @mbggenerated
+ */
+ private Date updateTime;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column tools.create_person
+ *
+ * @mbggenerated
+ */
+ private String createPerson;
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public Tool(Integer id, String type, String toolName, String toolIcon, String toolUrl, Date createTime, Date updateTime, String createPerson) {
+ this.id = id;
+ this.type = type;
+ this.toolName = toolName;
+ this.toolIcon = toolIcon;
+ this.toolUrl = toolUrl;
+ this.createTime = createTime;
+ this.updateTime = updateTime;
+ this.createPerson = createPerson;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public Tool() {
+ super();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column tools.id
+ *
+ * @return the value of tools.id
+ *
+ * @mbggenerated
+ */
+ public Integer getId() {
+ return id;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column tools.id
+ *
+ * @param id the value for tools.id
+ *
+ * @mbggenerated
+ */
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column tools.type
+ *
+ * @return the value of tools.type
+ *
+ * @mbggenerated
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column tools.type
+ *
+ * @param type the value for tools.type
+ *
+ * @mbggenerated
+ */
+ public void setType(String type) {
+ this.type = type == null ? null : type.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column tools.tool_name
+ *
+ * @return the value of tools.tool_name
+ *
+ * @mbggenerated
+ */
+ public String getToolName() {
+ return toolName;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column tools.tool_name
+ *
+ * @param toolName the value for tools.tool_name
+ *
+ * @mbggenerated
+ */
+ public void setToolName(String toolName) {
+ this.toolName = toolName == null ? null : toolName.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column tools.tool_icon
+ *
+ * @return the value of tools.tool_icon
+ *
+ * @mbggenerated
+ */
+ public String getToolIcon() {
+ return toolIcon;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column tools.tool_icon
+ *
+ * @param toolIcon the value for tools.tool_icon
+ *
+ * @mbggenerated
+ */
+ public void setToolIcon(String toolIcon) {
+ this.toolIcon = toolIcon == null ? null : toolIcon.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column tools.tool_url
+ *
+ * @return the value of tools.tool_url
+ *
+ * @mbggenerated
+ */
+ public String getToolUrl() {
+ return toolUrl;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column tools.tool_url
+ *
+ * @param toolUrl the value for tools.tool_url
+ *
+ * @mbggenerated
+ */
+ public void setToolUrl(String toolUrl) {
+ this.toolUrl = toolUrl == null ? null : toolUrl.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column tools.create_time
+ *
+ * @return the value of tools.create_time
+ *
+ * @mbggenerated
+ */
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column tools.create_time
+ *
+ * @param createTime the value for tools.create_time
+ *
+ * @mbggenerated
+ */
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column tools.update_time
+ *
+ * @return the value of tools.update_time
+ *
+ * @mbggenerated
+ */
+ public Date getUpdateTime() {
+ return updateTime;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column tools.update_time
+ *
+ * @param updateTime the value for tools.update_time
+ *
+ * @mbggenerated
+ */
+ public void setUpdateTime(Date updateTime) {
+ this.updateTime = updateTime;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column tools.create_person
+ *
+ * @return the value of tools.create_person
+ *
+ * @mbggenerated
+ */
+ public String getCreatePerson() {
+ return createPerson;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column tools.create_person
+ *
+ * @param createPerson the value for tools.create_person
+ *
+ * @mbggenerated
+ */
+ public void setCreatePerson(String createPerson) {
+ this.createPerson = createPerson == null ? null : createPerson.trim();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ning/dao/ToolExample.java b/src/main/java/com/ning/dao/ToolExample.java
new file mode 100644
index 0000000..d181fbb
--- /dev/null
+++ b/src/main/java/com/ning/dao/ToolExample.java
@@ -0,0 +1,833 @@
+package com.ning.dao;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class ToolExample {
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ protected String orderByClause;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ protected boolean distinct;
+
+ /**
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ protected List oredCriteria;
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public ToolExample() {
+ oredCriteria = new ArrayList();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public void setOrderByClause(String orderByClause) {
+ this.orderByClause = orderByClause;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public String getOrderByClause() {
+ return orderByClause;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public void setDistinct(boolean distinct) {
+ this.distinct = distinct;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public boolean isDistinct() {
+ return distinct;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public List getOredCriteria() {
+ return oredCriteria;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public void or(Criteria criteria) {
+ oredCriteria.add(criteria);
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public Criteria or() {
+ Criteria criteria = createCriteriaInternal();
+ oredCriteria.add(criteria);
+ return criteria;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public Criteria createCriteria() {
+ Criteria criteria = createCriteriaInternal();
+ if (oredCriteria.size() == 0) {
+ oredCriteria.add(criteria);
+ }
+ return criteria;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ protected Criteria createCriteriaInternal() {
+ Criteria criteria = new Criteria();
+ return criteria;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public void clear() {
+ oredCriteria.clear();
+ orderByClause = null;
+ distinct = false;
+ }
+
+ /**
+ * This class was generated by MyBatis Generator.
+ * This class corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ protected abstract static class GeneratedCriteria {
+ protected List criteria;
+
+ protected GeneratedCriteria() {
+ super();
+ criteria = new ArrayList();
+ }
+
+ public boolean isValid() {
+ return criteria.size() > 0;
+ }
+
+ public List getAllCriteria() {
+ return criteria;
+ }
+
+ public List getCriteria() {
+ return criteria;
+ }
+
+ protected void addCriterion(String condition) {
+ if (condition == null) {
+ throw new RuntimeException("Value for condition cannot be null");
+ }
+ criteria.add(new Criterion(condition));
+ }
+
+ protected void addCriterion(String condition, Object value, String property) {
+ if (value == null) {
+ throw new RuntimeException("Value for " + property + " cannot be null");
+ }
+ criteria.add(new Criterion(condition, value));
+ }
+
+ protected void addCriterion(String condition, Object value1, Object value2, String property) {
+ if (value1 == null || value2 == null) {
+ throw new RuntimeException("Between values for " + property + " cannot be null");
+ }
+ criteria.add(new Criterion(condition, value1, value2));
+ }
+
+ public Criteria andIdIsNull() {
+ addCriterion("id is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdIsNotNull() {
+ addCriterion("id is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdEqualTo(Integer value) {
+ addCriterion("id =", value, "id");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdNotEqualTo(Integer value) {
+ addCriterion("id <>", value, "id");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdGreaterThan(Integer value) {
+ addCriterion("id >", value, "id");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdGreaterThanOrEqualTo(Integer value) {
+ addCriterion("id >=", value, "id");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdLessThan(Integer value) {
+ addCriterion("id <", value, "id");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdLessThanOrEqualTo(Integer value) {
+ addCriterion("id <=", value, "id");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdIn(List values) {
+ addCriterion("id in", values, "id");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdNotIn(List values) {
+ addCriterion("id not in", values, "id");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdBetween(Integer value1, Integer value2) {
+ addCriterion("id between", value1, value2, "id");
+ return (Criteria) this;
+ }
+
+ public Criteria andIdNotBetween(Integer value1, Integer value2) {
+ addCriterion("id not between", value1, value2, "id");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeIsNull() {
+ addCriterion("type is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeIsNotNull() {
+ addCriterion("type is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeEqualTo(String value) {
+ addCriterion("type =", value, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeNotEqualTo(String value) {
+ addCriterion("type <>", value, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeGreaterThan(String value) {
+ addCriterion("type >", value, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeGreaterThanOrEqualTo(String value) {
+ addCriterion("type >=", value, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeLessThan(String value) {
+ addCriterion("type <", value, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeLessThanOrEqualTo(String value) {
+ addCriterion("type <=", value, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeLike(String value) {
+ addCriterion("type like", value, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeNotLike(String value) {
+ addCriterion("type not like", value, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeIn(List values) {
+ addCriterion("type in", values, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeNotIn(List values) {
+ addCriterion("type not in", values, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeBetween(String value1, String value2) {
+ addCriterion("type between", value1, value2, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andTypeNotBetween(String value1, String value2) {
+ addCriterion("type not between", value1, value2, "type");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameIsNull() {
+ addCriterion("tool_name is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameIsNotNull() {
+ addCriterion("tool_name is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameEqualTo(String value) {
+ addCriterion("tool_name =", value, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameNotEqualTo(String value) {
+ addCriterion("tool_name <>", value, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameGreaterThan(String value) {
+ addCriterion("tool_name >", value, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameGreaterThanOrEqualTo(String value) {
+ addCriterion("tool_name >=", value, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameLessThan(String value) {
+ addCriterion("tool_name <", value, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameLessThanOrEqualTo(String value) {
+ addCriterion("tool_name <=", value, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameLike(String value) {
+ addCriterion("tool_name like", value, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameNotLike(String value) {
+ addCriterion("tool_name not like", value, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameIn(List values) {
+ addCriterion("tool_name in", values, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameNotIn(List values) {
+ addCriterion("tool_name not in", values, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameBetween(String value1, String value2) {
+ addCriterion("tool_name between", value1, value2, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolNameNotBetween(String value1, String value2) {
+ addCriterion("tool_name not between", value1, value2, "toolName");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconIsNull() {
+ addCriterion("tool_icon is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconIsNotNull() {
+ addCriterion("tool_icon is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconEqualTo(String value) {
+ addCriterion("tool_icon =", value, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconNotEqualTo(String value) {
+ addCriterion("tool_icon <>", value, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconGreaterThan(String value) {
+ addCriterion("tool_icon >", value, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconGreaterThanOrEqualTo(String value) {
+ addCriterion("tool_icon >=", value, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconLessThan(String value) {
+ addCriterion("tool_icon <", value, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconLessThanOrEqualTo(String value) {
+ addCriterion("tool_icon <=", value, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconLike(String value) {
+ addCriterion("tool_icon like", value, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconNotLike(String value) {
+ addCriterion("tool_icon not like", value, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconIn(List values) {
+ addCriterion("tool_icon in", values, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconNotIn(List values) {
+ addCriterion("tool_icon not in", values, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconBetween(String value1, String value2) {
+ addCriterion("tool_icon between", value1, value2, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolIconNotBetween(String value1, String value2) {
+ addCriterion("tool_icon not between", value1, value2, "toolIcon");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlIsNull() {
+ addCriterion("tool_url is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlIsNotNull() {
+ addCriterion("tool_url is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlEqualTo(String value) {
+ addCriterion("tool_url =", value, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlNotEqualTo(String value) {
+ addCriterion("tool_url <>", value, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlGreaterThan(String value) {
+ addCriterion("tool_url >", value, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlGreaterThanOrEqualTo(String value) {
+ addCriterion("tool_url >=", value, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlLessThan(String value) {
+ addCriterion("tool_url <", value, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlLessThanOrEqualTo(String value) {
+ addCriterion("tool_url <=", value, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlLike(String value) {
+ addCriterion("tool_url like", value, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlNotLike(String value) {
+ addCriterion("tool_url not like", value, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlIn(List values) {
+ addCriterion("tool_url in", values, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlNotIn(List values) {
+ addCriterion("tool_url not in", values, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlBetween(String value1, String value2) {
+ addCriterion("tool_url between", value1, value2, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andToolUrlNotBetween(String value1, String value2) {
+ addCriterion("tool_url not between", value1, value2, "toolUrl");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeIsNull() {
+ addCriterion("create_time is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeIsNotNull() {
+ addCriterion("create_time is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeEqualTo(Date value) {
+ addCriterion("create_time =", value, "createTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeNotEqualTo(Date value) {
+ addCriterion("create_time <>", value, "createTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeGreaterThan(Date value) {
+ addCriterion("create_time >", value, "createTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+ addCriterion("create_time >=", value, "createTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeLessThan(Date value) {
+ addCriterion("create_time <", value, "createTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+ addCriterion("create_time <=", value, "createTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeIn(List values) {
+ addCriterion("create_time in", values, "createTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeNotIn(List values) {
+ addCriterion("create_time not in", values, "createTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeBetween(Date value1, Date value2) {
+ addCriterion("create_time between", value1, value2, "createTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+ addCriterion("create_time not between", value1, value2, "createTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeIsNull() {
+ addCriterion("update_time is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeIsNotNull() {
+ addCriterion("update_time is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeEqualTo(Date value) {
+ addCriterion("update_time =", value, "updateTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeNotEqualTo(Date value) {
+ addCriterion("update_time <>", value, "updateTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeGreaterThan(Date value) {
+ addCriterion("update_time >", value, "updateTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
+ addCriterion("update_time >=", value, "updateTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeLessThan(Date value) {
+ addCriterion("update_time <", value, "updateTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
+ addCriterion("update_time <=", value, "updateTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeIn(List values) {
+ addCriterion("update_time in", values, "updateTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeNotIn(List values) {
+ addCriterion("update_time not in", values, "updateTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeBetween(Date value1, Date value2) {
+ addCriterion("update_time between", value1, value2, "updateTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
+ addCriterion("update_time not between", value1, value2, "updateTime");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonIsNull() {
+ addCriterion("create_person is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonIsNotNull() {
+ addCriterion("create_person is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonEqualTo(String value) {
+ addCriterion("create_person =", value, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonNotEqualTo(String value) {
+ addCriterion("create_person <>", value, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonGreaterThan(String value) {
+ addCriterion("create_person >", value, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonGreaterThanOrEqualTo(String value) {
+ addCriterion("create_person >=", value, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonLessThan(String value) {
+ addCriterion("create_person <", value, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonLessThanOrEqualTo(String value) {
+ addCriterion("create_person <=", value, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonLike(String value) {
+ addCriterion("create_person like", value, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonNotLike(String value) {
+ addCriterion("create_person not like", value, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonIn(List values) {
+ addCriterion("create_person in", values, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonNotIn(List values) {
+ addCriterion("create_person not in", values, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonBetween(String value1, String value2) {
+ addCriterion("create_person between", value1, value2, "createPerson");
+ return (Criteria) this;
+ }
+
+ public Criteria andCreatePersonNotBetween(String value1, String value2) {
+ addCriterion("create_person not between", value1, value2, "createPerson");
+ return (Criteria) this;
+ }
+ }
+
+ /**
+ * This class was generated by MyBatis Generator.
+ * This class corresponds to the database table tools
+ *
+ * @mbggenerated do_not_delete_during_merge
+ */
+ public static class Criteria extends GeneratedCriteria {
+
+ protected Criteria() {
+ super();
+ }
+ }
+
+ /**
+ * This class was generated by MyBatis Generator.
+ * This class corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ public static class Criterion {
+ private String condition;
+
+ private Object value;
+
+ private Object secondValue;
+
+ private boolean noValue;
+
+ private boolean singleValue;
+
+ private boolean betweenValue;
+
+ private boolean listValue;
+
+ private String typeHandler;
+
+ public String getCondition() {
+ return condition;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Object getSecondValue() {
+ return secondValue;
+ }
+
+ public boolean isNoValue() {
+ return noValue;
+ }
+
+ public boolean isSingleValue() {
+ return singleValue;
+ }
+
+ public boolean isBetweenValue() {
+ return betweenValue;
+ }
+
+ public boolean isListValue() {
+ return listValue;
+ }
+
+ public String getTypeHandler() {
+ return typeHandler;
+ }
+
+ protected Criterion(String condition) {
+ super();
+ this.condition = condition;
+ this.typeHandler = null;
+ this.noValue = true;
+ }
+
+ protected Criterion(String condition, Object value, String typeHandler) {
+ super();
+ this.condition = condition;
+ this.value = value;
+ this.typeHandler = typeHandler;
+ if (value instanceof List>) {
+ this.listValue = true;
+ } else {
+ this.singleValue = true;
+ }
+ }
+
+ protected Criterion(String condition, Object value) {
+ this(condition, value, null);
+ }
+
+ protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+ super();
+ this.condition = condition;
+ this.value = value;
+ this.secondValue = secondValue;
+ this.typeHandler = typeHandler;
+ this.betweenValue = true;
+ }
+
+ protected Criterion(String condition, Object value, Object secondValue) {
+ this(condition, value, secondValue, null);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ning/domain/BlogSearchVO.java b/src/main/java/com/ning/domain/BlogSearchVO.java
index 4297358..29c8d9c 100644
--- a/src/main/java/com/ning/domain/BlogSearchVO.java
+++ b/src/main/java/com/ning/domain/BlogSearchVO.java
@@ -8,6 +8,7 @@ public class BlogSearchVO {
private Long id;
private String title;
private Integer type;
+ private String tag;
public Long getId() {
return id;
@@ -32,4 +33,12 @@ public Integer getType() {
public void setType(Integer type) {
this.type = type;
}
+
+ public String getTag() {
+ return tag;
+ }
+
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
}
diff --git a/src/main/java/com/ning/domain/BlogSubtype.java b/src/main/java/com/ning/domain/BlogSubtype.java
index abc168b..908f951 100644
--- a/src/main/java/com/ning/domain/BlogSubtype.java
+++ b/src/main/java/com/ning/domain/BlogSubtype.java
@@ -9,6 +9,8 @@ public class BlogSubtype {
private String subTitle;
+ private String imageUrl;
+
private Date createTime;
private String updateTime;
@@ -62,4 +64,12 @@ public String getCreatePerson() {
public void setCreatePerson(String createPerson) {
this.createPerson = createPerson == null ? null : createPerson.trim();
}
+
+ public String getImageUrl() {
+ return imageUrl;
+ }
+
+ public void setImageUrl(String imageUrl) {
+ this.imageUrl = imageUrl;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/ning/mapper/BlogContentMapper.java b/src/main/java/com/ning/mapper/BlogContentMapper.java
index f49d164..4e0ca80 100644
--- a/src/main/java/com/ning/mapper/BlogContentMapper.java
+++ b/src/main/java/com/ning/mapper/BlogContentMapper.java
@@ -5,6 +5,7 @@
import com.ning.domain.BlogSearchVO;
import com.xiaomi.platform.xmybatis.plugins.Pagination;
import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
import java.util.List;
@@ -28,4 +29,8 @@ public interface BlogContentMapper {
// @Select("select * from blog_content order by visit_count desc limit 10;")
List getBestList();
+
+
+ @Select("select tags from blog_content")
+ List getTags();
}
\ No newline at end of file
diff --git a/src/main/java/com/ning/mapper/BlogSubtypeMapper.java b/src/main/java/com/ning/mapper/BlogSubtypeMapper.java
index a05c8bb..5603c4e 100644
--- a/src/main/java/com/ning/mapper/BlogSubtypeMapper.java
+++ b/src/main/java/com/ning/mapper/BlogSubtypeMapper.java
@@ -2,6 +2,7 @@
import com.ning.domain.BlogSubtype;
+import com.xiaomi.platform.xmybatis.plugins.Pagination;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -19,6 +20,10 @@ public interface BlogSubtypeMapper {
int updateByPrimaryKey(BlogSubtype record);
+ List getsublistByPage(Pagination pagination, @Param("type")BlogSubtype type);
+
List getsublist(@Param("type") int type);
+ int countSubType(@Param("subtype")BlogSubtype subtype);
+
}
\ No newline at end of file
diff --git a/src/main/java/com/ning/mapper/HouseRecordMapper.java b/src/main/java/com/ning/mapper/HouseRecordMapper.java
new file mode 100644
index 0000000..52b2b52
--- /dev/null
+++ b/src/main/java/com/ning/mapper/HouseRecordMapper.java
@@ -0,0 +1,27 @@
+package com.ning.mapper;
+
+import com.ning.dao.HouseRecord;
+import com.xiaomi.platform.xmybatis.plugins.Pagination;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface HouseRecordMapper {
+ int deleteByPrimaryKey(Integer id);
+
+ int insert(HouseRecord record);
+
+ int insertSelective(HouseRecord record);
+
+ HouseRecord selectByPrimaryKey(Integer id);
+
+ int countByTitle(@Param("title") String title);
+
+ int updateByPrimaryKeySelective(HouseRecord record);
+
+ int updateByPrimaryKey(HouseRecord record);
+
+ List getBlogListByPage(Pagination pagination,@Param("record") HouseRecord record);
+}
\ No newline at end of file
diff --git a/src/main/java/com/ning/mapper/ToolMapper.java b/src/main/java/com/ning/mapper/ToolMapper.java
new file mode 100644
index 0000000..d997755
--- /dev/null
+++ b/src/main/java/com/ning/mapper/ToolMapper.java
@@ -0,0 +1,108 @@
+package com.ning.mapper;
+
+import com.ning.dao.Tool;
+import com.ning.dao.ToolExample;
+import java.util.List;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.ResultMap;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+public interface ToolMapper {
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ int countByExample(ToolExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ @Delete({
+ "delete from tools",
+ "where id = #{id,jdbcType=INTEGER}"
+ })
+ int deleteByPrimaryKey(Integer id);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ @Insert({
+ "insert into tools (id, type, tool_name, ",
+ "tool_icon, tool_url, ",
+ "create_time, update_time, ",
+ "create_person)",
+ "values (#{id,jdbcType=INTEGER}, #{type,jdbcType=CHAR}, #{toolName,jdbcType=VARCHAR}, ",
+ "#{toolIcon,jdbcType=VARCHAR}, #{toolUrl,jdbcType=VARCHAR}, ",
+ "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
+ "#{createPerson,jdbcType=VARCHAR})"
+ })
+ int insert(Tool record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ int insertSelective(Tool record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ List selectByExample(ToolExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ @Select({
+ "select",
+ "id, type, tool_name, tool_icon, tool_url, create_time, update_time, create_person",
+ "from tools",
+ "where id = #{id,jdbcType=INTEGER}"
+ })
+ @ResultMap("BaseResultMap")
+ Tool selectByPrimaryKey(Integer id);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ int updateByPrimaryKeySelective(Tool record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table tools
+ *
+ * @mbggenerated
+ */
+ @Update({
+ "update tools",
+ "set type = #{type,jdbcType=CHAR},",
+ "tool_name = #{toolName,jdbcType=VARCHAR},",
+ "tool_icon = #{toolIcon,jdbcType=VARCHAR},",
+ "tool_url = #{toolUrl,jdbcType=VARCHAR},",
+ "create_time = #{createTime,jdbcType=TIMESTAMP},",
+ "update_time = #{updateTime,jdbcType=TIMESTAMP},",
+ "create_person = #{createPerson,jdbcType=VARCHAR}",
+ "where id = #{id,jdbcType=INTEGER}"
+ })
+ int updateByPrimaryKey(Tool record);
+}
\ No newline at end of file
diff --git a/src/main/java/com/ning/mapper/UserMapper.java b/src/main/java/com/ning/mapper/UserMapper.java
index 77bd33e..28967d9 100644
--- a/src/main/java/com/ning/mapper/UserMapper.java
+++ b/src/main/java/com/ning/mapper/UserMapper.java
@@ -20,4 +20,6 @@ public interface UserMapper {
List getUserList();
+
+
}
\ No newline at end of file
diff --git a/src/main/java/com/ning/serviceimpl/BasicServiceImpl.java b/src/main/java/com/ning/serviceimpl/BasicServiceImpl.java
index 314c24d..9c9d5a2 100644
--- a/src/main/java/com/ning/serviceimpl/BasicServiceImpl.java
+++ b/src/main/java/com/ning/serviceimpl/BasicServiceImpl.java
@@ -10,11 +10,16 @@
* Created by ning on 12/8/15.
*/
-@Service("BasicService")
+@Service("basicService")
public class BasicServiceImpl implements BasicService{
@Autowired
private UserService userService;
+
+ public User getLoginAdmin(String key) {
+ return null;
+ }
+
@Override
public User getLoginAdmin() {
return null;
diff --git a/src/main/java/com/ning/serviceimpl/BlogServiceImpl.java b/src/main/java/com/ning/serviceimpl/BlogServiceImpl.java
index c9d8513..50857a2 100644
--- a/src/main/java/com/ning/serviceimpl/BlogServiceImpl.java
+++ b/src/main/java/com/ning/serviceimpl/BlogServiceImpl.java
@@ -37,6 +37,10 @@ public List getTagList(){
public List getBlogList(Pagination page,BlogSearchVO searchVO){
return blogContentMapper.getBlogListByPage(page,searchVO);
}
+
+ public List getSubtypeListbyPage(Pagination page,BlogSubtype searchVO){
+ return blogSubtypeMapper.getsublistByPage(page,searchVO);
+ }
public List getBestList(){
return blogContentMapper.getBestList();
}
@@ -45,6 +49,11 @@ public List getSubtypeList(int type){
return blogSubtypeMapper.getsublist(type);
}
+
+ public BlogSubtype getSubtype(Short id){
+ return blogSubtypeMapper.selectByPrimaryKey(id);
+ }
+
/**
* 正则匹配获取部分内容
* @param list
@@ -52,22 +61,24 @@ public List getSubtypeList(int type){
*/
public List getFixBlogList(List list){
for(BlogContent blogContent:list){
- String regex="(.*?
)";
+ String regex="<[a-zA-Z]+.*?>([\\s\\S]*?)[a-zA-Z]*>";
+ StringBuilder builder=new StringBuilder();
Pattern p = Pattern.compile(regex);
Matcher m=p.matcher(blogContent.getBlogContent());
- boolean result=m.find();
int length=0;
- while(result){
- result=m.find();
- if(result){
- length=m.start();
- if(length>1000){
+ while(m.find()) {
+ String data = m.group(1).trim();
+ if(!"".equals(data)) {
+ System.out.println(data);
+ length=builder.length();
+ if(length>200){
break;
}
+ builder.append(data);
}
}
- System.out.println(blogContent.getBlogContent().substring(0,length));
- blogContent.setBlogContent(blogContent.getBlogContent().substring(0,length));
+
+ blogContent.setBlogContent(builder.toString());
}
return list;
diff --git a/src/main/java/com/ning/serviceimpl/RedisService.java b/src/main/java/com/ning/serviceimpl/RedisService.java
index 8e21f5e..06c9274 100644
--- a/src/main/java/com/ning/serviceimpl/RedisService.java
+++ b/src/main/java/com/ning/serviceimpl/RedisService.java
@@ -2,14 +2,12 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.ning.mapper.BlogContentMapper;
import com.ning.utils.SerializeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
-import org.springframework.data.redis.core.BoundHashOperations;
-import org.springframework.data.redis.core.ListOperations;
-import org.springframework.data.redis.core.RedisCallback;
-import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.stereotype.Service;
@@ -23,19 +21,41 @@
@Service
public class RedisService {
@Autowired
- private RedisTemplate template;
+ private RedisTemplate template; //注意泛型的类型设置,否则导致存储数据的格式问题。
+
+ @Autowired
+ private RedisTemplate templateString;
+
@Resource(name="redisTemplate")
private ListOperations listOps;
+ @Resource(name="redisTemplate")
+ private HashOperations hashOps;
+
+ @Autowired
+ private BlogContentMapper blogContentMapper;
+
private static String HASHKEY="hashtest";
+ private static String TAGSKEY="tags";
+ /**
+ * Add link.
+ *
+ * @param userId the user id
+ * @param url the url
+ */
public void addLink(String userId,String url){
/**不指定redis key名字,使用本机用户名 */
-
listOps.leftPush(userId,url);
}
+ /**
+ * Get link list.
+ *
+ * @param userId the user id
+ * @return the list
+ */
public List getLink(final String userId){
/**不指定redis key名字,使用本机用户名 */
final List returnValue= Lists.newArrayList();
@@ -57,13 +77,86 @@ public Object doInRedis(RedisConnection redisConnection) throws DataAccessExcept
return returnValue;
}
- /**add hash*/
+ /**
+ * Get tags list.
+ *
+ * @return the list
+ */
+ public List getTags(){
+ /**不指定redis key名字,使用本机用户名 */
+ if(listOps.size(TAGSKEY)<=0){
+ List filterTags=Lists.newArrayList();
+ List tags= blogContentMapper.getTags();
+ for(String tag:tags){
+ String[] tagstrs=tag.split(" +");
+ for(String item:tagstrs){
+ if(filterTags.contains(item))
+ continue;
+ filterTags.add(item);
+ }
+ }
+ for(String item:filterTags){
+ listOps.rightPush(TAGSKEY,item);
+ }
+
+ }
+ return listOps.range(TAGSKEY,0,listOps.size(TAGSKEY)-1);
+ }
+
+
+ public boolean cleanTags(){
+ listOps.range(TAGSKEY,0,-1);
+ return true;
+ }
+
+ /**
+ * Append.
+ *
+ * @param key the key
+ * @param param the param
+ */
+ public void append(final String key,String param) {
+ /**不指定redis key名字,使用本机用户名 */
+ long result;
+ final byte[] addBytes = param.getBytes();
+ template.opsForValue().append(key,param);
+ }
+
+
+ /**
+ * Get string string.
+ *
+ * @param key the key
+ * @return the string
+ */
+ public String getString(final String key){
+ /**不指定redis key名字,使用本机用户名 */
+// byte[] keyBytes=key.getBytes();
+ String result=templateString.opsForValue().get(key);
+ return result;
+ }
+
+
+ /**
+ * add hash @param key the key
+ *
+ * @param value the value
+ * @return the boolean
+ */
public boolean addHash(String key,String value){
RedisSerializer redisSerializer=template.getHashKeySerializer();
template.boundHashOps(HASHKEY).put(key,value);
+ template.opsForHash().put(HASHKEY,key,value);
return true;
}
+ /**
+ * Set hash boolean.
+ *
+ * @param key the key
+ * @param value the value
+ * @return the boolean
+ */
public boolean setHash(String key,String value){
RedisSerializer redisSerializer=template.getHashKeySerializer();
template.boundHashOps(HASHKEY).put(key,value);
@@ -72,7 +165,8 @@ public boolean setHash(String key,String value){
/**
* get all hashmap
- * @return
+ *
+ * @return map
*/
public Map getHash(){
Map allhash= Maps.newHashMap();
diff --git a/src/main/java/com/ning/serviceimpl/TestServiceImp.java b/src/main/java/com/ning/serviceimpl/TestServiceImp.java
new file mode 100644
index 0000000..35accec
--- /dev/null
+++ b/src/main/java/com/ning/serviceimpl/TestServiceImp.java
@@ -0,0 +1,78 @@
+package com.ning.serviceimpl;
+
+import com.ning.domain.User;
+import com.ning.mapper.UserMapper;
+import com.ning.services.TestService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+
+/**
+ * Created by ning on 2016-11-03.
+ */
+@Service
+public class TestServiceImp implements TestService {
+
+ private static final Logger logger = LoggerFactory.getLogger(TestServiceImp.class);
+
+ @Autowired
+ private UserMapper userMapper;
+
+ @Override
+ public void uncommitUserRead() {
+ try {
+ Thread.sleep(200);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ User user=userMapper.selectByPrimaryKey(2);
+ Assert.notNull(user);
+ logger.info("user info:"+user.getId()+user.getUsername());
+ }
+
+ @Override
+ public void uncommitUserUpdate() {
+ User user=new User();
+ user.setId(2L);
+ user.setUsername("newTest");
+ userMapper.updateByPrimaryKeySelective(user);
+ logger.info("update user info:"+user.getId()+user.getUsername());
+ try {
+ Thread.sleep(200);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void commitUserRead() {
+
+ }
+
+ @Override
+ public void commitUserUpdate() {
+
+ }
+
+ @Override
+ public void repeatUserRead() {
+
+ }
+
+ @Override
+ public void repeatUserUpdate() {
+
+ }
+
+ @Override
+ public void serialUserUpdate() {
+
+ }
+
+ @Override
+ public void commitUserInsert() {
+
+ }
+}
diff --git a/src/main/java/com/ning/serviceimpl/ToolService.java b/src/main/java/com/ning/serviceimpl/ToolService.java
new file mode 100644
index 0000000..f037962
--- /dev/null
+++ b/src/main/java/com/ning/serviceimpl/ToolService.java
@@ -0,0 +1,120 @@
+package com.ning.serviceimpl;
+
+import com.ning.dao.Tool;
+import com.ning.dao.ToolExample;
+import com.ning.domain.BlogSubtype;
+import com.ning.mapper.BlogSubtypeMapper;
+import com.ning.mapper.ToolMapper;
+import com.ning.services.BasicService;
+import com.ning.services.IToolService;
+import com.xiaomi.platform.xmybatis.plugins.Pagination;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by ning on 2016-11-10.
+ */
+
+@Service("toolService")
+public class ToolService implements IToolService {
+
+ private static final Logger logger = LoggerFactory.getLogger(ToolService.class);
+
+ @Autowired
+ protected ToolMapper toolMapper;
+ @Autowired
+ protected BlogSubtypeMapper subtypeMapper;
+
+ @Resource
+ private BasicService basicService;
+
+ @Override
+ public List getToolsbyPage(Pagination page,Tool tool) {
+ ToolExample toolExample=null;
+ if(tool!=null){
+ toolExample= _buildExampleByWhere(tool.getId(),tool.getToolName(),tool.getType());
+ }
+ return toolMapper.selectByExample(toolExample);
+ }
+
+ @Override
+ public List getTools() {
+ return null;
+ }
+
+
+ @Override
+ public void insertTool(Tool tool,String user) throws Exception{
+ Assert.notNull(tool);
+ Date now=new Date();
+ tool.setCreateTime(now);
+ tool.setUpdateTime(now);
+ tool.setCreatePerson(user);
+ ToolExample toolExample= _buildExampleByWhere(tool.getId(),tool.getToolName(),tool.getType());
+ if(toolMapper.countByExample(toolExample)>0)
+ {
+ logger.debug("insert tool exception:this tool is exsit.");
+ return ;
+ }
+
+ toolMapper.insertSelective(tool);
+ }
+
+ @Override
+ public int deleteTool(Integer id) {
+ return toolMapper.deleteByPrimaryKey(id);
+ }
+
+ @Override
+ public int deleteSubType(Short id) {
+ return subtypeMapper.deleteByPrimaryKey(id);
+ }
+
+ @Override
+ public Integer updateTool(Tool tool) {
+ return toolMapper.updateByPrimaryKeySelective(tool);
+ }
+
+ @Override
+ public Tool getTool(Integer id) {
+ return toolMapper.selectByPrimaryKey(id);
+ }
+
+ private ToolExample _buildExampleByWhere(Integer id, String title, String type){
+ ToolExample example=new ToolExample();
+ ToolExample.Criteria criteria=example.createCriteria();
+ if(id!=null && id>0){
+ criteria.andToolNameEqualTo(title);
+ }
+ if(StringUtils.isNotEmpty(title)){
+ criteria.andToolNameEqualTo(title);
+ }
+ if(StringUtils.isNotEmpty(type)){
+ criteria.andTypeEqualTo(type);
+ }
+ return example;
+ }
+
+ @Override
+ public void insertSubType(BlogSubtype type, String user) throws Exception {
+ Assert.notNull(type);
+ Date now=new Date();
+ type.setCreateTime(now);
+ type.setUpdateTime(now.toString());
+ type.setCreatePerson(user);
+ if(subtypeMapper.countSubType(type)>0)
+ {
+ logger.debug("insert type exception:this type is exsit.");
+ throw new Exception("type is exist!");
+ }
+ subtypeMapper.insertSelective(type);
+ }
+}
diff --git a/src/main/java/com/ning/services/CrawlerService.java b/src/main/java/com/ning/services/CrawlerService.java
new file mode 100644
index 0000000..1ad4e51
--- /dev/null
+++ b/src/main/java/com/ning/services/CrawlerService.java
@@ -0,0 +1,57 @@
+package com.ning.services;
+
+import com.ning.crawler.LjCrawler;
+import edu.uci.ics.crawler4j.crawler.CrawlConfig;
+import edu.uci.ics.crawler4j.crawler.CrawlController;
+import edu.uci.ics.crawler4j.fetcher.PageFetcher;
+import edu.uci.ics.crawler4j.robotstxt.RobotstxtConfig;
+import edu.uci.ics.crawler4j.robotstxt.RobotstxtServer;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Created by oliver on 2017/2/16.
+ */
+@Service
+public class CrawlerService implements ICrawlerService{
+
+ @Transactional(value="transactionManager",rollbackFor ={Throwable.class})
+ public void crawling() throws Exception {
+ String crawlStorageFolder = "/Users/oliver/test/crawler";
+ int numberOfCrawlers = 3;
+
+ CrawlConfig config = new CrawlConfig();
+ config.setCrawlStorageFolder(crawlStorageFolder);
+
+ /*
+ * Instantiate the controller for this crawl.
+ */
+ PageFetcher pageFetcher = new PageFetcher(config);
+ RobotstxtConfig robotstxtConfig = new RobotstxtConfig();
+ robotstxtConfig.setEnabled(false);
+ RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher);
+ CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer);
+
+ /*
+ * For each crawl, you need to add some seed urls. These are the first
+ * URLs that are fetched and then the crawler starts following links
+ * which are found in these pages
+ */
+// controller.addSeed("http://bj.lianjia.com/ershoufang/haidian/");
+
+ controller.addSeed("http://qd.lianjia.com/ershoufang/");
+
+
+
+ /*
+ * Start the crawl. This is a blocking operation, meaning that your code
+ * will reach the line after this only when crawling is finished.
+ */
+ controller.start(LjCrawler.class, numberOfCrawlers);
+ }
+
+// @Override
+// public void crawling() throws Exception {
+//
+// }
+}
diff --git a/src/main/java/com/ning/services/ICrawlerService.java b/src/main/java/com/ning/services/ICrawlerService.java
new file mode 100644
index 0000000..9a97a13
--- /dev/null
+++ b/src/main/java/com/ning/services/ICrawlerService.java
@@ -0,0 +1,8 @@
+package com.ning.services;
+
+/**
+ * Created by oliver on 2017/2/16.
+ */
+public interface ICrawlerService {
+ public void crawling() throws Exception;
+}
diff --git a/src/main/java/com/ning/services/ILjService.java b/src/main/java/com/ning/services/ILjService.java
new file mode 100644
index 0000000..b598387
--- /dev/null
+++ b/src/main/java/com/ning/services/ILjService.java
@@ -0,0 +1,14 @@
+package com.ning.services;
+
+import com.ning.dao.HouseRecord;
+import com.xiaomi.platform.xmybatis.plugins.Pagination;
+
+import java.util.List;
+
+/**
+ * Created by oliver on 2017/2/16.
+ */
+public interface ILjService {
+
+ public List getHouseRecordListByPage(Pagination pagination, HouseRecord record);
+}
diff --git a/src/main/java/com/ning/services/IToolService.java b/src/main/java/com/ning/services/IToolService.java
new file mode 100644
index 0000000..25c2074
--- /dev/null
+++ b/src/main/java/com/ning/services/IToolService.java
@@ -0,0 +1,30 @@
+package com.ning.services;
+
+import com.ning.dao.Tool;
+import com.ning.domain.BlogSubtype;
+import com.xiaomi.platform.xmybatis.plugins.Pagination;
+
+import java.util.List;
+
+/**
+ * Created by ning on 2016-11-10.
+ */
+
+
+public interface IToolService {
+ List getTools();
+
+ List getToolsbyPage(Pagination page, Tool tool);
+
+ void insertTool(Tool tool, String user) throws Exception;
+
+ void insertSubType(BlogSubtype type, String user) throws Exception;
+
+ int deleteTool(Integer id);
+
+ int deleteSubType(Short id);
+
+ Integer updateTool(Tool tool);
+
+ Tool getTool(Integer id);
+}
diff --git a/src/main/java/com/ning/services/LjService.java b/src/main/java/com/ning/services/LjService.java
new file mode 100644
index 0000000..4e70d42
--- /dev/null
+++ b/src/main/java/com/ning/services/LjService.java
@@ -0,0 +1,23 @@
+package com.ning.services;
+
+import com.ning.dao.HouseRecord;
+import com.ning.mapper.HouseRecordMapper;
+import com.xiaomi.platform.xmybatis.plugins.Pagination;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * Created by oliver on 2017/2/16.
+ */
+@Service("ljService")
+public class LjService implements ILjService {
+
+ @Autowired
+ private HouseRecordMapper houseRecordMapper;
+
+ public List getHouseRecordListByPage(Pagination pagination,HouseRecord record) {
+ return houseRecordMapper.getBlogListByPage(pagination,record);
+ }
+}
diff --git a/src/main/java/com/ning/services/TestService.java b/src/main/java/com/ning/services/TestService.java
new file mode 100644
index 0000000..a7e5cf9
--- /dev/null
+++ b/src/main/java/com/ning/services/TestService.java
@@ -0,0 +1,49 @@
+package com.ning.services;
+
+/**
+ * 事务隔离级别测试
+ * Created by ning on 2016-11-03.
+ */
+public interface TestService {
+
+ /**
+ * Uncommit user read.
+ */
+ public void uncommitUserRead();
+
+ /**
+ * Uncommit user update.
+ */
+ public void uncommitUserUpdate();
+
+ /**
+ * Commit user read.
+ */
+ public void commitUserRead();
+
+ /**
+ * Commit user update.
+ */
+ public void commitUserUpdate();
+
+ /**
+ * Repeat user read.
+ */
+ public void repeatUserRead();
+
+ /**
+ * Repeat user update.
+ */
+ public void repeatUserUpdate();
+
+ /**
+ * Serial user update.
+ */
+ public void serialUserUpdate();
+
+ /**
+ * Commit user insert.
+ */
+ public void commitUserInsert();
+
+}
diff --git a/src/main/java/com/ning/utils/SpringBeanFactoryUtils.java b/src/main/java/com/ning/utils/SpringBeanFactoryUtils.java
new file mode 100644
index 0000000..70a9fc1
--- /dev/null
+++ b/src/main/java/com/ning/utils/SpringBeanFactoryUtils.java
@@ -0,0 +1,51 @@
+package com.ning.utils;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Created by oliver on 2017/2/16.
+ * 普通类也可以使用此工具 获取bean 对象
+ * 在applicationContext.xml文件中配置
+ *
+ 1
+
+ */
+public class SpringBeanFactoryUtils implements ApplicationContextAware {
+
+ private static ApplicationContext appCtx;
+
+ /**
+ * 此方法可以把ApplicationContext对象inject到当前类中作为一个静态成员变量。
+ *
+ * @param applicationContext ApplicationContext 对象.
+ * @throws BeansException
+ * @author wangdf
+ */
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ SpringBeanFactoryUtils.appCtx = applicationContext;
+ }
+
+ /**
+ * 获取ApplicationContext
+ *
+ * @return
+ * @author wangdf
+ */
+ public static ApplicationContext getApplicationContext() {
+ return appCtx;
+ }
+
+ /**
+ * 这是一个便利的方法,帮助我们快速得到一个BEAN
+ *
+ * @param beanName bean的名字
+ * @return 返回一个bean对象
+ * @author wangdf
+ */
+ public static Object getBean(String beanName) {
+ return appCtx.getBean(beanName);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/resources/com/ning/mapping/BlogContentMapper.xml b/src/main/resources/com/ning/mapping/BlogContentMapper.xml
index 05bd4e1..fb30d1f 100644
--- a/src/main/resources/com/ning/mapping/BlogContentMapper.xml
+++ b/src/main/resources/com/ning/mapping/BlogContentMapper.xml
@@ -172,6 +172,9 @@
and blog_title like CONCAT('%', #{searchVO.title},'%')
+
+ and tags like CONCAT('%',#{searchVO.tag},'%')
+
order by create_time desc
diff --git a/src/main/resources/com/ning/mapping/BlogSubtypeMapper.xml b/src/main/resources/com/ning/mapping/BlogSubtypeMapper.xml
index e128a1e..8571211 100644
--- a/src/main/resources/com/ning/mapping/BlogSubtypeMapper.xml
+++ b/src/main/resources/com/ning/mapping/BlogSubtypeMapper.xml
@@ -5,12 +5,13 @@
+
- id, category_id, sub_title, create_time, update_time, create_person
+ id, category_id, sub_title,imageurl, create_time, update_time, create_person
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/com/ning/mapping/HouseRecordMapper.xml b/src/main/resources/com/ning/mapping/HouseRecordMapper.xml
new file mode 100644
index 0000000..73ffc01
--- /dev/null
+++ b/src/main/resources/com/ning/mapping/HouseRecordMapper.xml
@@ -0,0 +1,174 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, title, address, descri, area, follow_info, price, unit_price, create_time, create_person
+
+
+
+
+
+
+
+
+
+
+
+
+ delete from lianjia_source
+ where id = #{id,jdbcType=INTEGER}
+
+
+
+ insert into lianjia_source (id, title, address,
+ descri, area, follow_info,
+ price, unit_price, create_time,
+ create_person)
+ values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR},
+ #{descri,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR}, #{followInfo,jdbcType=VARCHAR},
+ #{price,jdbcType=DECIMAL}, #{unitPrice,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP},
+ #{createPerson,jdbcType=VARCHAR})
+
+
+ insert into lianjia_source
+
+
+ id,
+
+
+ title,
+
+
+ address,
+
+
+ descri,
+
+
+ area,
+
+
+ follow_info,
+
+
+ price,
+
+
+ unit_price,
+
+
+ create_time,
+
+
+ create_person,
+
+
+
+
+ #{id,jdbcType=INTEGER},
+
+
+ #{title,jdbcType=VARCHAR},
+
+
+ #{address,jdbcType=VARCHAR},
+
+
+ #{descri,jdbcType=VARCHAR},
+
+
+ #{area,jdbcType=VARCHAR},
+
+
+ #{followInfo,jdbcType=VARCHAR},
+
+
+ #{price,jdbcType=DECIMAL},
+
+
+ #{unitPrice,jdbcType=DECIMAL},
+
+
+ #{createTime,jdbcType=TIMESTAMP},
+
+
+ #{createPerson,jdbcType=VARCHAR},
+
+
+
+
+ update lianjia_source
+
+
+ title = #{title,jdbcType=VARCHAR},
+
+
+ address = #{address,jdbcType=VARCHAR},
+
+
+ descri = #{descri,jdbcType=VARCHAR},
+
+
+ area = #{area,jdbcType=VARCHAR},
+
+
+ follow_info = #{followInfo,jdbcType=VARCHAR},
+
+
+ price = #{price,jdbcType=DECIMAL},
+
+
+ unit_price = #{unitPrice,jdbcType=DECIMAL},
+
+
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+
+
+ create_person = #{createPerson,jdbcType=VARCHAR},
+
+
+ where id = #{id,jdbcType=INTEGER}
+
+
+ update lianjia_source
+ set title = #{title,jdbcType=VARCHAR},
+ address = #{address,jdbcType=VARCHAR},
+ descri = #{descri,jdbcType=VARCHAR},
+ area = #{area,jdbcType=VARCHAR},
+ follow_info = #{followInfo,jdbcType=VARCHAR},
+ price = #{price,jdbcType=DECIMAL},
+ unit_price = #{unitPrice,jdbcType=DECIMAL},
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+ create_person = #{createPerson,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=INTEGER}
+
+
\ No newline at end of file
diff --git a/src/main/resources/com/ning/mapping/ToolMapper.xml b/src/main/resources/com/ning/mapping/ToolMapper.xml
new file mode 100644
index 0000000..108a51e
--- /dev/null
+++ b/src/main/resources/com/ning/mapping/ToolMapper.xml
@@ -0,0 +1,179 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ and ${criterion.condition}
+
+
+ and ${criterion.condition} #{criterion.value}
+
+
+ and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+
+
+ and ${criterion.condition}
+
+ #{listItem}
+
+
+
+
+
+
+
+
+
+
+
+ id, type, tool_name, tool_icon, tool_url, create_time, update_time, create_person
+
+
+
+
+ insert into tools
+
+
+ id,
+
+
+ type,
+
+
+ tool_name,
+
+
+ tool_icon,
+
+
+ tool_url,
+
+
+ create_time,
+
+
+ update_time,
+
+
+ create_person,
+
+
+
+
+ #{id,jdbcType=INTEGER},
+
+
+ #{type,jdbcType=CHAR},
+
+
+ #{toolName,jdbcType=VARCHAR},
+
+
+ #{toolIcon,jdbcType=VARCHAR},
+
+
+ #{toolUrl,jdbcType=VARCHAR},
+
+
+ #{createTime,jdbcType=TIMESTAMP},
+
+
+ #{updateTime,jdbcType=TIMESTAMP},
+
+
+ #{createPerson,jdbcType=VARCHAR},
+
+
+
+
+
+
+ update tools
+
+
+ type = #{type,jdbcType=CHAR},
+
+
+ tool_name = #{toolName,jdbcType=VARCHAR},
+
+
+ tool_icon = #{toolIcon,jdbcType=VARCHAR},
+
+
+ tool_url = #{toolUrl,jdbcType=VARCHAR},
+
+
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+
+
+ update_time = #{updateTime,jdbcType=TIMESTAMP},
+
+
+ create_person = #{createPerson,jdbcType=VARCHAR},
+
+
+ where id = #{id,jdbcType=INTEGER}
+
+
\ No newline at end of file
diff --git a/src/main/resources/ehcache.xml b/src/main/resources/config/ehcache.xml
similarity index 98%
rename from src/main/resources/ehcache.xml
rename to src/main/resources/config/ehcache.xml
index abdb96a..862bdd2 100644
--- a/src/main/resources/ehcache.xml
+++ b/src/main/resources/config/ehcache.xml
@@ -1,4 +1,4 @@
-
+
diff --git a/src/main/resources/config/jdbc.properties b/src/main/resources/config/jdbc.properties
index 493fbde..152c12b 100644
--- a/src/main/resources/config/jdbc.properties
+++ b/src/main/resources/config/jdbc.properties
@@ -1,18 +1,17 @@
-driver=com.mysql.jdbc.Driver
-
-#url=jdbc:mysql://127.0.0.1:3306/oliver_blog
+##
+jdbc.driver=com.mysql.jdbc.Driver
+##url=jdbc:mysql://127.0.0.1:3306/oliver_blog
#username=root
-
-url=jdbc:mysql://127.0.0.1:3306/go_developer
-username=root
-password=root
+jdbc.url=jdbc:mysql://127.0.0.1:3306/go_developer
+jdbc.username=root
+jdbc.password=
#定义初始连接数
-initialSize=0
+jdbc.initialSize=0
#定义最大连接数
-maxActive=20
+jdbc.maxActive=20
#定义最大空闲
-maxIdle=20
+jdbc.maxIdle=20
#定义最小空闲
-minIdle=1
+jdbc.minIdle=1
#定义最长等待时间
-maxWait=60000
\ No newline at end of file
+jdbc.maxWait=60000
\ No newline at end of file
diff --git a/src/main/resources/config/mybatis/mybatis.xml b/src/main/resources/config/mybatis/mybatis.xml
index e8edbc3..4ee49d4 100644
--- a/src/main/resources/config/mybatis/mybatis.xml
+++ b/src/main/resources/config/mybatis/mybatis.xml
@@ -1,18 +1,13 @@
-
-
-
-
-
+
-
+
-
+
@@ -31,5 +26,4 @@
-
diff --git a/src/main/resources/config/spring/applicationContext-dao.xml b/src/main/resources/config/spring/applicationContext-dao.xml
index ad94bcf..48d3b01 100644
--- a/src/main/resources/config/spring/applicationContext-dao.xml
+++ b/src/main/resources/config/spring/applicationContext-dao.xml
@@ -4,42 +4,78 @@
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
+ http://www.springframework.org/schema/tx
+ http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
+ http://www.springframework.org/schema/util/spring-util.xsd" >
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
@@ -86,13 +122,12 @@
-
-
-
+
+
@@ -147,7 +182,6 @@
-
@@ -171,7 +205,7 @@
-
+
@@ -199,8 +233,6 @@
-
-
diff --git a/src/main/resources/config/spring/applicationContext-redis.xml b/src/main/resources/config/spring/applicationContext-redis.xml
index 08610ec..8e5288f 100644
--- a/src/main/resources/config/spring/applicationContext-redis.xml
+++ b/src/main/resources/config/spring/applicationContext-redis.xml
@@ -1,19 +1,22 @@
-
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context.xsd">
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
@@ -32,6 +35,7 @@
+
diff --git a/src/main/resources/config/spring/applicationContext-service.xml b/src/main/resources/config/spring/applicationContext-service.xml
index 4575bff..2f7e954 100644
--- a/src/main/resources/config/spring/applicationContext-service.xml
+++ b/src/main/resources/config/spring/applicationContext-service.xml
@@ -6,9 +6,7 @@
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/config/spring/applicationContext-springmvc.xml b/src/main/resources/config/spring/applicationContext-springmvc.xml
index 3150b22..7845fc5 100644
--- a/src/main/resources/config/spring/applicationContext-springmvc.xml
+++ b/src/main/resources/config/spring/applicationContext-springmvc.xml
@@ -76,6 +76,9 @@
+
+
+
@@ -117,6 +120,7 @@
+
diff --git a/src/main/resources/config/spring/applicationContext-transtion.xml b/src/main/resources/config/spring/applicationContext-transtion.xml
index 97b7668..fdc2cc3 100644
--- a/src/main/resources/config/spring/applicationContext-transtion.xml
+++ b/src/main/resources/config/spring/applicationContext-transtion.xml
@@ -1,20 +1,30 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/generator.properties b/src/main/resources/generator.properties
index 746aedd..d43a59e 100644
--- a/src/main/resources/generator.properties
+++ b/src/main/resources/generator.properties
@@ -1,4 +1,4 @@
-jdbc.driver=com.mysql.jdbc.Driver
-jdbc.url=jdbc:mysql://127.0.0.1:3306/go_developer
-jdbc.username=root
-jdbc.password=root
+#jdbc.driver=com.mysql.jdbc.Driver
+#jdbc.url=jdbc:mysql://127.0.0.1:3306/go_developer
+#jdbc.username=root
+#jdbc.password=root
diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml
index fa76960..3f1b3be 100644
--- a/src/main/resources/generatorConfig.xml
+++ b/src/main/resources/generatorConfig.xml
@@ -87,7 +87,10 @@
-
+
+
+
Oliver's Blogs
-
-
+ <#include "./common/base_static_file.ftl"/>
-
-
-
-
Keep calm and Carry on
-