├── pointlikerobot.iml ├── pom.xml ├── src ├── main │ ├── java │ │ └── com │ │ │ └── lifeix │ │ │ └── robot │ │ │ ├── controller │ │ │ └── PointLikeController.java │ │ │ ├── dao │ │ │ ├── PointLikeAccountDao.java │ │ │ └── PointLikeAccountDetailDao.java │ │ │ ├── job │ │ │ └── PointLikeJob.java │ │ │ ├── model │ │ │ ├── PointLikeAccount.java │ │ │ └── PointLikeAccountDetail.java │ │ │ ├── mongo │ │ │ └── PointLikeAccountMongoService.java │ │ │ ├── util │ │ │ └── ReadFile.java │ │ │ └── vo │ │ │ └── AccountContentVO.java │ └── resources │ │ ├── application.xml │ │ ├── jdbc.properties │ │ ├── log4j.properties │ │ ├── mapper │ │ ├── PointLikeAccountDao.xml │ │ └── PointLikeAccountDetailDao.xml │ │ ├── mongodb.properties │ │ ├── spring-mvc.xml │ │ └── spring-mybatis.xml └── test │ └── java │ └── com │ └── lifeix │ └── test │ └── MyTest.java └── web ├── WEB-INF ├── errorpage │ ├── 404.jsp │ ├── 405.jsp │ └── 500.jsp ├── jsp │ └── index.jsp └── web.xml └── index.jsp /pointlikerobot.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | pointlikerobot 8 | pointlikerobot 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | 14 | 4.0.6.RELEASE 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | org.springframework 120 | spring-context 121 | ${spring.version} 122 | 123 | 124 | org.springframework 125 | spring-web 126 | ${spring.version} 127 | 128 | 129 | org.springframework 130 | spring-aop 131 | ${spring.version} 132 | 133 | 134 | org.springframework 135 | spring-tx 136 | ${spring.version} 137 | 138 | 139 | org.springframework 140 | spring-aspects 141 | ${spring.version} 142 | 143 | 144 | org.springframework 145 | spring-beans 146 | ${spring.version} 147 | 148 | 149 | org.springframework 150 | spring-context-support 151 | ${spring.version} 152 | 153 | 154 | org.springframework 155 | spring-core 156 | ${spring.version} 157 | 158 | 159 | org.springframework 160 | spring-orm 161 | ${spring.version} 162 | 163 | 164 | org.springframework 165 | spring-test 166 | ${spring.version} 167 | 168 | 169 | org.springframework 170 | spring-webmvc 171 | ${spring.version} 172 | 173 | 174 | 175 | org.slf4j 176 | slf4j-api 177 | 1.6.2 178 | 179 | 180 | org.slf4j 181 | slf4j-jdk14 182 | 1.6.2 183 | 184 | 185 | 186 | log4j 187 | log4j 188 | 1.2.14 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | org.quartz-scheduler 213 | quartz 214 | 2.2.1 215 | 216 | 217 | 218 | 219 | org.springframework.data 220 | spring-data-mongodb 221 | 1.5.4.RELEASE 222 | 223 | 224 | 225 | org.slf4j 226 | slf4j-log4j12 227 | 1.5.8 228 | 229 | 230 | 231 | 232 | junit 233 | junit 234 | 4.11 235 | 236 | 237 | 238 | 239 | 240 | org.mybatis 241 | mybatis 242 | 3.2.4 243 | 244 | 245 | 246 | org.mybatis 247 | mybatis-spring 248 | 1.2.2 249 | 250 | 251 | 252 | mysql 253 | mysql-connector-java 254 | 5.1.29 255 | 256 | 257 | 258 | 259 | com.alibaba 260 | druid 261 | 1.0.2 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | -------------------------------------------------------------------------------- /src/main/java/com/lifeix/robot/controller/PointLikeController.java: -------------------------------------------------------------------------------- 1 | package com.lifeix.robot.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.ResponseBody; 6 | import org.springframework.web.servlet.ModelAndView; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * Created by lhx on 15-2-5 下午2:49 13 | * 14 | * @project point-like-robot 15 | * @package com.lifeix.robot.controller 16 | * @Description 17 | * @blog http://blog.csdn.net/u011439289 18 | * @email 888xin@sina.com 19 | * @github https://github.com/888xin 20 | */ 21 | @Controller 22 | @RequestMapping("/robot") 23 | public class PointLikeController { 24 | 25 | // @Autowired 26 | // private Determine determine ; 27 | // @Autowired 28 | // private AccountCommonAction accountCommonAction ; 29 | // @Autowired 30 | // private PointLikeAccountJob pointLikeAccountJob ; 31 | // @Autowired 32 | // private PointLikeJob pointLikeJob ; 33 | // 34 | // 35 | @RequestMapping("/runjob") 36 | public ModelAndView runJob(String pointedAccountId, String pointedGender){ 37 | // System.out.println(pointedAccountId + "====" + pointedGender); 38 | // SchedulerQuartz schedulerQuartz = new SchedulerQuartz(); 39 | // try { 40 | // schedulerQuartz.run(pointedAccountId,pointedGender); 41 | // } catch (Exception e) { 42 | // e.printStackTrace(); 43 | // } 44 | // //未来3-10分钟内触发 45 | // int minutes = (int)Math.round(Math.random()*7) + 3 ; 46 | // //3-15的点赞数 47 | // int repeatcounts = (int)Math.round(Math.random()*15) + 3 ; 48 | // //点赞间隔intervalSeconds 49 | // int intervalSeconds = (int)Math.round(Math.random()*60) + 20 ; 50 | // try { 51 | //// Thread.sleep(1000L * 60 * minutes); 52 | // System.out.println(minutes); 53 | // Thread.sleep(1000L * minutes); 54 | // pointLikeAccountJob.work(pointedAccountId, pointedGender); 55 | // for (int i = 0; i < repeatcounts; i++) { 56 | // System.out.println(repeatcounts); 57 | // System.out.println(intervalSeconds); 58 | // Thread.sleep(1000L * intervalSeconds); 59 | // pointLikeAccountJob.work(pointedAccountId, pointedGender); 60 | // } 61 | // } catch (InterruptedException e) { 62 | // e.printStackTrace(); 63 | // } 64 | return null ; 65 | 66 | } 67 | 68 | /** 69 | * 跳入service层判断用户发表的内容是否需要点赞 70 | * @param pointedAccountId 71 | * @return 72 | */ 73 | @RequestMapping("/determineaccount") 74 | public String determineAccount(String pointedAccountId){ 75 | // if (!"".equals(pointedAccountId)){ 76 | // long accountid = Long.valueOf(pointedAccountId); 77 | // //需要点赞的用户 78 | // if ( determine.determineAccount(accountid) ){ 79 | // //查找用户文章、性别 80 | //// com.l99.dto.account.Account account = userService.userinfo(accountid); 81 | //// int gender = account.getAccountType(); 82 | //// return "redirect:/robot/runjob?pointedGender="+gender + "&pointedAccountId=" + accountid ; 83 | // String content = accountCommonAction.findAccountProfileById(accountid); 84 | // String pointedGender = content.substring(content.indexOf("gender") + 8, content.indexOf("gender") + 9); 85 | // return "redirect:/robot/runjob.do?pointedAccountId=" + accountid + "&pointedGender=" + pointedGender ; 86 | // } else { 87 | // System.out.println( accountCommonAction.findAccountProfileById(accountid)); 88 | // return "redirect:/robot/backfalse.do" ; 89 | // } 90 | // } else { 91 | // return "redirect:/robot/backfalse.do" ; 92 | // } 93 | return null ; 94 | } 95 | 96 | @RequestMapping("/backfalse") 97 | @ResponseBody 98 | public Map backfalse(){ 99 | Map outmap = new HashMap(); 100 | outmap.put("flag",false); 101 | return outmap ; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/lifeix/robot/dao/PointLikeAccountDao.java: -------------------------------------------------------------------------------- 1 | package com.lifeix.robot.dao; 2 | 3 | import com.lifeix.robot.model.PointLikeAccount; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by lhx on 15-2-4 下午2:30 9 | * 10 | * @project point-like-robot 11 | * @package com.lifeix.robot.dao 12 | * @Description 13 | * @blog http://blog.csdn.net/u011439289 14 | * @email 888xin@sina.com 15 | * @github https://github.com/888xin 16 | */ 17 | public interface PointLikeAccountDao { 18 | 19 | /** 20 | * 添加数据 21 | */ 22 | public int insertpointLikeAccount(PointLikeAccount pointLikeAccount); 23 | 24 | public List getpointLikeAccounts(int sex); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/lifeix/robot/dao/PointLikeAccountDetailDao.java: -------------------------------------------------------------------------------- 1 | package com.lifeix.robot.dao; 2 | 3 | import com.lifeix.robot.model.PointLikeAccountDetail; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by lhx on 15-2-4 下午5:08 9 | * 10 | * @project point-like-robot 11 | * @package com.lifeix.robot.dao 12 | * @Description 13 | * @blog http://blog.csdn.net/u011439289 14 | * @email 888xin@sina.com 15 | * @github https://github.com/888xin 16 | */ 17 | public interface PointLikeAccountDetailDao { 18 | 19 | /** 20 | * 添加数据 21 | */ 22 | public int insertPointLikeAccountDetail(PointLikeAccountDetail pointLikeAccount); 23 | 24 | /** 25 | * 获取数据 26 | */ 27 | public List getPointLikeAccountDetails(Integer sex); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/lifeix/robot/job/PointLikeJob.java: -------------------------------------------------------------------------------- 1 | package com.lifeix.robot.job; 2 | 3 | 4 | import com.lifeix.robot.dao.PointLikeAccountDao; 5 | import com.lifeix.robot.dao.PointLikeAccountDetailDao; 6 | import com.lifeix.robot.model.PointLikeAccount; 7 | import com.lifeix.robot.model.PointLikeAccountDetail; 8 | import com.lifeix.robot.mongo.PointLikeAccountMongoService; 9 | import com.lifeix.robot.vo.AccountContentVO; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.text.SimpleDateFormat; 14 | import java.util.Calendar; 15 | import java.util.Date; 16 | import java.util.List; 17 | 18 | /** 19 | * Created by xin on 15-2-7 上午10:32 20 | * 21 | * @project praiseRobot 22 | * @package com.lifeix.robot.task 23 | * @Description 24 | * @blog http://blog.csdn.net/u011439289 25 | * @email 888xin@sina.com 26 | * @github https://github.com/888xin 27 | */ 28 | @Service 29 | public class PointLikeJob { 30 | 31 | @Autowired 32 | private PointLikeAccountDao pointLikeAccountDao ; 33 | @Autowired 34 | private PointLikeAccountDetailDao pointLikeAccountDetailDao ; 35 | @Autowired 36 | private PointLikeAccountMongoService pointLikeAccountMongoService; 37 | 38 | 39 | public void work(){ 40 | System.out.println("work"); 41 | //获取需要判断的用户列表 42 | List accountContentVOList = pointLikeAccountMongoService.get(false); 43 | if (accountContentVOList == null || accountContentVOList.size()==0){ 44 | System.out.println("work is over!"); 45 | } else { 46 | //现在的时间 47 | Date currentTime = new Date(); 48 | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 49 | String startdate = formatter.format(currentTime); 50 | //一个月前 51 | Calendar cal = Calendar.getInstance(); 52 | cal.add(Calendar.MONTH, -1); 53 | String enddate = formatter.format(cal.getTime()); 54 | for (AccountContentVO accountContentVO : accountContentVOList) { 55 | //更新mongodb数据,把状态设为true 56 | pointLikeAccountMongoService.update(accountContentVO.getDashboardId()); 57 | //循环判断是否需要点赞 58 | //int n = commentServiceClient.getAccountLikeNOByTime(Long.valueOf(pointedAccountId), false, startdate, enddate); 59 | int n = 13 ; 60 | if (n < 15) { 61 | //获取点赞人,分男女 62 | List listboy = pointLikeAccountDao.getpointLikeAccounts(1); 63 | List listgirl = pointLikeAccountDao.getpointLikeAccounts(0); 64 | //被点赞人性别 65 | int pointedGender = accountContentVO.getPointedGender(); 66 | //被点赞人accountID 67 | long pointedAccountId = accountContentVO.getAccountId(); 68 | //被点赞人文章ID 69 | long dashboardId = accountContentVO.getDashboardId(); 70 | //3-15的点赞数 71 | int repeatcounts = (int)Math.round(Math.random()*15) + 3 ; 72 | for (int i = 0; i < repeatcounts; i++) { 73 | //主键生成 74 | //Long gobalKey = IdentityUtil.getLocalCacheId(CommonConstant.APPLICATION_CONTENT_CENTER,RobotModuleEnums.POINT_LIKE_ROBOT.getName(), RobotTableEnums.POINT_LIKE_ACCOUNT_DETAIL.getName()); 75 | Long gobalKey = (long)Math.round(Math.random()*1000000000); 76 | //点赞人随机性别 一方占70%,另一方占30% 77 | int sexrandom = (int)Math.round(Math.random()*10) ; 78 | //与被点赞人性别相反 79 | if (sexrandom < 8){ 80 | if (pointedGender == 1){ 81 | //女性点赞人 82 | savelike(listgirl, pointedGender, pointedAccountId, dashboardId, gobalKey); 83 | } else { 84 | //男性点赞人 85 | savelike(listboy, pointedGender, pointedAccountId, dashboardId, gobalKey); 86 | } 87 | } else { 88 | if (pointedGender == 1){ 89 | //男性点赞人 90 | savelike(listboy, pointedGender, pointedAccountId, dashboardId, gobalKey); 91 | } else { 92 | //女性点赞人 93 | savelike(listgirl, pointedGender, pointedAccountId, dashboardId, gobalKey); 94 | } 95 | } 96 | } 97 | } else { 98 | 99 | } 100 | } 101 | } 102 | } 103 | 104 | private void savelike(List list, int pointedGender, long pointedAccountId, long dashboardId, Long gobalKey) { 105 | //获取点赞人 106 | int pointrandom = (int)Math.round(Math.random()*(list.size())) ; 107 | PointLikeAccount pointLikeAccount = list.get(pointrandom); 108 | //去掉使用的点赞人,防止重复。 109 | list.remove(pointrandom); 110 | PointLikeAccountDetail pointLikeAccountDetail = new PointLikeAccountDetail(); 111 | pointLikeAccountDetail.setId(gobalKey); 112 | //被点赞人性别 113 | pointLikeAccountDetail.setPointedGender(pointedGender); 114 | //被点赞人accountID 115 | pointLikeAccountDetail.setPointedAccountId(pointedAccountId); 116 | //点赞人性别 117 | pointLikeAccountDetail.setPointGender(0); 118 | //点赞人的accountID 119 | pointLikeAccountDetail.setPointAccountId(pointLikeAccount.getPointAccountId()); 120 | //点赞时间 121 | pointLikeAccountDetail.setPointTime(new Date()); 122 | //被点赞文章ID 123 | pointLikeAccountDetail.setDashboardId(dashboardId); 124 | //点赞表情,五个随机中获取 125 | int likeExpression = (int)Math.round(Math.random()*5) ; 126 | pointLikeAccountDetail.setLikeExpression(likeExpression); 127 | pointLikeAccountDetailDao.insertPointLikeAccountDetail(pointLikeAccountDetail); 128 | //点赞间隔intervalSeconds 129 | int intervalSeconds = (int)Math.round(Math.random()*60) + 20 ; 130 | try { 131 | Thread.sleep(1000L*intervalSeconds); 132 | } catch (InterruptedException e) { 133 | e.printStackTrace(); 134 | } 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/com/lifeix/robot/model/PointLikeAccount.java: -------------------------------------------------------------------------------- 1 | package com.lifeix.robot.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by lhx on 15-2-4 下午2:28 7 | * 8 | * @project point-like-robot 9 | * @package com.lifeix.robot.dao 10 | * @Description 11 | * @blog http://blog.csdn.net/u011439289 12 | * @email 888xin@sina.com 13 | * @github https://github.com/888xin 14 | */ 15 | public class PointLikeAccount implements Serializable { 16 | 17 | private Long id ; 18 | private Long pointAccountId ; 19 | private int pointGender ; 20 | 21 | public Long getId() { 22 | return id; 23 | } 24 | 25 | public void setId(Long id) { 26 | this.id = id; 27 | } 28 | 29 | public Long getPointAccountId() { 30 | return pointAccountId; 31 | } 32 | 33 | public void setPointAccountId(Long pointAccountId) { 34 | this.pointAccountId = pointAccountId; 35 | } 36 | 37 | public int getPointGender() { 38 | return pointGender; 39 | } 40 | 41 | public void setPointGender(int pointGender) { 42 | this.pointGender = pointGender; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/lifeix/robot/model/PointLikeAccountDetail.java: -------------------------------------------------------------------------------- 1 | package com.lifeix.robot.model; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created by lhx on 15-2-4 下午5:02 8 | * 9 | * @project point-like-robot 10 | * @package com.lifeix.robot.model 11 | * @Description 12 | * @blog http://blog.csdn.net/u011439289 13 | * @email 888xin@sina.com 14 | * @github https://github.com/888xin 15 | */ 16 | public class PointLikeAccountDetail implements Serializable { 17 | 18 | private Long id ; 19 | private Long pointAccountId ; 20 | private Integer pointGender ; 21 | private Long pointedAccountId ; 22 | private Integer pointedGender ; 23 | private Date pointTime ; 24 | private String remark ; 25 | private Long dashboardId ; 26 | private Integer likeExpression; //点赞表情 27 | 28 | public Integer getLikeExpression() { 29 | return likeExpression; 30 | } 31 | 32 | public void setLikeExpression(Integer likeExpression) { 33 | this.likeExpression = likeExpression; 34 | } 35 | 36 | public Long getDashboardId() { 37 | return dashboardId; 38 | } 39 | 40 | public void setDashboardId(Long dashboardId) { 41 | this.dashboardId = dashboardId; 42 | } 43 | 44 | public String getRemark() { 45 | return remark; 46 | } 47 | 48 | public void setRemark(String remark) { 49 | this.remark = remark; 50 | } 51 | 52 | public Long getId() { 53 | return id; 54 | } 55 | 56 | public void setId(Long id) { 57 | this.id = id; 58 | } 59 | 60 | public Long getPointAccountId() { 61 | return pointAccountId; 62 | } 63 | 64 | public void setPointAccountId(Long pointAccountId) { 65 | this.pointAccountId = pointAccountId; 66 | } 67 | 68 | public Integer getPointGender() { 69 | return pointGender; 70 | } 71 | 72 | public void setPointGender(Integer pointGender) { 73 | this.pointGender = pointGender; 74 | } 75 | 76 | public Long getPointedAccountId() { 77 | return pointedAccountId; 78 | } 79 | 80 | public void setPointedAccountId(Long pointedAccountId) { 81 | this.pointedAccountId = pointedAccountId; 82 | } 83 | 84 | public Integer getPointedGender() { 85 | return pointedGender; 86 | } 87 | 88 | public void setPointedGender(Integer pointedGender) { 89 | this.pointedGender = pointedGender; 90 | } 91 | 92 | public Date getPointTime() { 93 | return pointTime; 94 | } 95 | 96 | public void setPointTime(Date pointTime) { 97 | this.pointTime = pointTime; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/lifeix/robot/mongo/PointLikeAccountMongoService.java: -------------------------------------------------------------------------------- 1 | package com.lifeix.robot.mongo; 2 | 3 | import com.lifeix.robot.vo.AccountContentVO; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.data.mongodb.core.MongoTemplate; 6 | import org.springframework.data.mongodb.core.query.Criteria; 7 | import org.springframework.data.mongodb.core.query.Query; 8 | import org.springframework.data.mongodb.core.query.Update; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.text.SimpleDateFormat; 12 | import java.util.Calendar; 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by lhx on 15-2-6 下午8:11 18 | * 19 | * @project point-like-robot 20 | * @package com.lifeix.robot.service.impl 21 | * @Description 22 | * @blog http://blog.csdn.net/u011439289 23 | * @email 888xin@sina.com 24 | * @github https://github.com/888xin 25 | */ 26 | @Service 27 | public class PointLikeAccountMongoService { 28 | 29 | @Autowired 30 | private MongoTemplate mongoTemplate ; 31 | 32 | /** 33 | * 插入数据 34 | * @param dashboardId 35 | * @param accountId 36 | * @param createTime 37 | */ 38 | public void insert(long dashboardId, long accountId, Date createTime) { 39 | AccountContentVO accountContentVO = new AccountContentVO(); 40 | accountContentVO.setAccountId(accountId); 41 | accountContentVO.setDashboardId(dashboardId); 42 | accountContentVO.setStatus(false); 43 | accountContentVO.setCreateTime(createTime); 44 | mongoTemplate.insert(accountContentVO,"accountcontent"); 45 | } 46 | 47 | /** 48 | * 根据状态获取数据 49 | * @param status true表示处理过的,false表示未处理过 50 | * @return AccountContentVO集合 51 | */ 52 | public List get(boolean status) { 53 | return mongoTemplate.find(new Query(Criteria.where("status").is(status)), AccountContentVO.class, "accountcontent"); 54 | } 55 | 56 | /** 57 | * 获取minutes内新插入的数据 58 | * @param minutes minutes分钟内 59 | * @return AccountContentVO集合 60 | */ 61 | public List getByTime(int minutes){ 62 | //现在的时间 63 | Date currentTime = new Date(); 64 | //minutes分钟前 65 | Calendar cal = Calendar.getInstance(); 66 | cal.add(Calendar.MINUTE, -minutes); 67 | Date end = cal.getTime(); 68 | Query query = new Query(); 69 | Criteria criteria = Criteria.where("createTime").gte(end).lte(currentTime); 70 | query.addCriteria(criteria); 71 | return mongoTemplate.find(query, AccountContentVO.class, "accountcontent"); 72 | } 73 | 74 | public List getByNumbers(boolean status, int numbers){ 75 | return mongoTemplate.find(new Query(Criteria.where("status").is(status)).limit(numbers), AccountContentVO.class, "accountcontent"); 76 | } 77 | 78 | /** 79 | * 根据文章号更新状态,false变为true 80 | * @param dashboardId 文章ID 81 | */ 82 | public void update(long dashboardId){ 83 | mongoTemplate.upsert(new Query(Criteria.where("dashboardId").is(dashboardId)), Update.update("status", true), "accountcontent"); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/lifeix/robot/util/ReadFile.java: -------------------------------------------------------------------------------- 1 | package com.lifeix.robot.util; 2 | 3 | import java.io.*; 4 | import java.sql.SQLException; 5 | import java.util.HashSet; 6 | import java.util.Set; 7 | 8 | /** 9 | * Created by lhx on 15-1-5 下午1:44 10 | * 11 | * @project anti 12 | * @package com.lifeix.anti.common.util 13 | * @Description 读文件操作类 14 | * @blog http://blog.csdn.net/u011439289 15 | * @email 888xin@sina.com 16 | * @github https://github.com/888xin 17 | */ 18 | public class ReadFile { 19 | 20 | public static String[] readTxtByLine(File file){ 21 | try { 22 | //字符流 23 | FileReader reader = new FileReader(file) ; 24 | BufferedReader br = new BufferedReader(reader); 25 | String line = "" ; 26 | StringBuilder buffer = new StringBuilder(); 27 | while ((line = br.readLine()) != null){ 28 | buffer.append(line).append("-----"); 29 | } 30 | int n = buffer.lastIndexOf("-----") ; 31 | buffer.deleteCharAt(n); 32 | buffer.deleteCharAt(n); 33 | buffer.deleteCharAt(n); 34 | buffer.deleteCharAt(n); 35 | buffer.deleteCharAt(n); 36 | String[] arrs = buffer.toString().split("-----"); 37 | br.close(); 38 | reader.close(); 39 | return arrs ; 40 | } catch (Exception e){ 41 | e.printStackTrace(); 42 | return null ; 43 | } 44 | } 45 | 46 | public static String[] readTxtByLine(File file, String encode){ 47 | try { 48 | //字节流 49 | FileInputStream in = new FileInputStream(file); 50 | InputStreamReader isr = new InputStreamReader(in,encode); 51 | BufferedReader br = new BufferedReader(isr); 52 | String line = "" ; 53 | StringBuilder buffer = new StringBuilder(); 54 | while ((line = br.readLine()) != null){ 55 | buffer.append(line).append("-----"); 56 | } 57 | int n = buffer.lastIndexOf("-----") ; 58 | buffer.deleteCharAt(n); 59 | buffer.deleteCharAt(n); 60 | buffer.deleteCharAt(n); 61 | buffer.deleteCharAt(n); 62 | buffer.deleteCharAt(n); 63 | String[] arrs = buffer.toString().split("-----"); 64 | br.close(); 65 | isr.close(); 66 | in.close(); 67 | return arrs ; 68 | } catch (Exception e){ 69 | e.printStackTrace(); 70 | return null ; 71 | } 72 | } 73 | 74 | public static String readTxt(File file, String encode){ 75 | try { 76 | //字节流 77 | FileInputStream in = new FileInputStream(file); 78 | InputStreamReader isr = new InputStreamReader(in,encode); 79 | BufferedReader br = new BufferedReader(isr); 80 | String line = "" ; 81 | StringBuilder buffer = new StringBuilder(); 82 | // buffer.append(file.getAbsolutePath()); 83 | while ((line = br.readLine()) != null){ 84 | buffer.append(line); 85 | } 86 | br.close(); 87 | isr.close(); 88 | in.close(); 89 | return buffer.toString() ; 90 | } catch (Exception e){ 91 | e.printStackTrace(); 92 | return null ; 93 | } 94 | } 95 | 96 | public static Set ReadTxtInDirectory(String strPath){ 97 | File path = new File(strPath); 98 | if (!path.exists() || !path.isDirectory()){ 99 | return null ; 100 | } else { 101 | String[] files = path.list(); 102 | Set set = new HashSet(); 103 | for (String file : files) { 104 | if (file != null && !"".equals(file) && file.endsWith(".txt")){ 105 | String string = readTxt(new File(strPath + File.separator + file), "UTF-8"); 106 | set.add(string); 107 | } 108 | } 109 | return set ; 110 | } 111 | } 112 | 113 | public static void main(String[] args) throws IOException, SQLException { 114 | 115 | 116 | 117 | 118 | // File file = new File("C:\\Users\\Lifeix\\Desktop\\文档中含有敏感词汇\\新建文本文档.txt"); 119 | // String[] strs = readTxtByLine(file,"gbk"); 120 | // StringBuilder stringBuilder1 = new StringBuilder(); 121 | // List list = new ArrayList(); 122 | // for (String str : strs) { 123 | // str = str.trim(); 124 | // if (!"".equals(str) && str != null && str.length()>2){ 125 | // String str1 = SplitSentence.splitWordBySpace(str) ; 126 | // str1 = MyStringUtil.deleteChineseCharacter(str1); 127 | // str1 = MyStringUtil.formatChinese(str1).trim(); 128 | // if (!"".equals(str1)){ 129 | // System.out.println(str1); 130 | // stringBuilder1.append(str).append(":::::").append(str1).append("======"); 131 | // } else { 132 | // list.add(str); 133 | // } 134 | // } 135 | // } 136 | // String[] strs1 = stringBuilder1.toString().split("======"); 137 | // WriteLines writeLines = new WriteLines(new File("C:\\Users\\Lifeix\\Desktop\\all\\新建文件夹\\01.txt")); 138 | // writeLines.WriteLineByEncode(strs1,"gbk"); 139 | // int length = list.size(); 140 | // String[] strs2 = new String[length]; 141 | // for (int i = 0; i < length; i++) { 142 | // strs2[i] = list.get(i); 143 | // } 144 | // WriteLines writeLines2 = new WriteLines(new File("C:\\Users\\Lifeix\\Desktop\\all\\新建文件夹\\02.txt")); 145 | // writeLines2.WriteLineByEncode(strs2,"gbk"); 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | // //读入整个文件夹里面的txt文档 156 | // String pref = "13" ; 157 | // String strPath = "C:\\Users\\Lifeix\\Desktop\\all\\new_dir\\" + pref ; 158 | // File path = new File(strPath); 159 | // Map map = new HashMap(); 160 | // if (!path.exists() || !path.isDirectory()){ 161 | // System.out.println(""); 162 | // } else { 163 | // String[] files = path.list(); 164 | // for (String file : files) { 165 | // if (file != null && !"".equals(file) && file.endsWith(".txt")){ 166 | // //读入文档内容 167 | // String string = readTxt(new File(strPath + File.separator + file), "UTF-8"); 168 | // map.put(file, string); 169 | // } 170 | // } 171 | // } 172 | // StringBuilder stringBuilder1 = new StringBuilder(); 173 | // List list = new ArrayList(); 174 | // for (String key : map.keySet()) { 175 | // String str = map.get(key); 176 | // str = str.trim(); 177 | // if (!"".equals(str)){ 178 | // str = SplitSentence.splitWordBySpace(str) ; 179 | // str = MyStringUtil.deleteChineseCharacter(str); 180 | // str = MyStringUtil.formatChinese(str).trim(); 181 | // if (!"".equals(str)){ 182 | // System.out.println(str); 183 | // stringBuilder1.append(key).append(":::::").append(str).append("======"); 184 | // } else { 185 | // list.add(key); 186 | // } 187 | // } 188 | // 189 | // } 190 | // String[] strs1 = stringBuilder1.toString().split("======"); 191 | // //生成文件夹 192 | // String createPath = "C:\\Users\\Lifeix\\Desktop\\文档中含有敏感词汇\\" + pref ; 193 | // File createfile = new File(createPath); 194 | // if (!createfile .exists()){ 195 | // createfile.mkdir(); 196 | // } 197 | // WriteLines writeLines = new WriteLines(new File(createPath + "\\有敏感词.txt")); 198 | // writeLines.WriteLineByEncode(strs1,"gbk"); 199 | // int length = list.size(); 200 | // String[] strs2 = new String[length]; 201 | // for (int i = 0; i < length; i++) { 202 | // strs2[i] = list.get(i); 203 | // } 204 | // WriteLines writeLines2 = new WriteLines(new File(createPath + "\\无敏感词.txt")); 205 | // writeLines2.WriteLineByEncode(strs2,"gbk"); 206 | 207 | 208 | 209 | 210 | //数据库插入数据 211 | // File file = new File("C:\\Users\\Lifeix\\Desktop\\all\\新建文件夹\\去重后.txt"); 212 | // String[] strs = readTxtByLine(file,"gbk"); 213 | // Connection connection = JdbcUtils.getConnection("jdbc:mysql://192.168.2.3:3306/anti_center","skst","TestDBSkst$@"); 214 | // String sql = "INSERT into illegal_user_info(id,illegal_user_register_info,status,remarks) VALUES(?,?,?,?)"; 215 | // PreparedStatement prest = connection.prepareStatement(sql); 216 | // long n = 1 ; 217 | // for (String str : strs) { 218 | // prest.setLong(1, n); 219 | // prest.setString(2, str.trim()); 220 | // prest.setBoolean(3, true); 221 | // prest.setString(4, "非法账户名"); 222 | // n ++ ; 223 | // prest.execute(); 224 | // } 225 | // JdbcUtils.free(null, null, connection); 226 | 227 | 228 | 229 | String str = ""; 230 | str = str.replaceAll(" ","\t") ; 231 | System.out.println(str); 232 | 233 | 234 | // File file = new File("C:\\Users\\Lifeix\\Desktop\\敏感词库\\我\\立方敏感内容.txt"); 235 | // String[] strs = readTxtByLine(file,"gbk"); 236 | // List list = new ArrayList(); 237 | // for (String str : strs) { 238 | // String[] sss = str.split(","); 239 | // for (String ss : sss) { 240 | // list.add(ss); 241 | // } 242 | // } 243 | // String[] ss2 = new String[list.size()]; 244 | // for (int i = 0; i < list.size(); i++) { 245 | // ss2[i] = list.get(i); 246 | // } 247 | // WriteLines writeLines = new WriteLines(new File("C:\\Users\\Lifeix\\Desktop\\敏感词库\\我\\分开敏感词2.txt")); 248 | // writeLines.WriteLineByEncode(ss2,"gbk"); 249 | 250 | // File file = new File("C:\\Users\\Lifeix\\Desktop\\3.txt"); 251 | // String[] strs = readTxtByLine(file,"gbk"); 252 | // Connection connection = JdbcUtils2.getConnection("jdbc:mysql://192.168.2.3:3306/anti_center?characterEncoding=UTF8", 253 | // "skst", "TestDBSkst$@") ; 254 | // List> mapList = new ArrayList>(); 255 | // Map map = null ; 256 | // for (int i = 0; i < strs.length; i++) { 257 | // map = new HashMap(); 258 | // map.put("serviceKind", "10,11,12"); 259 | // map.put("sensitive_word", strs[i]); 260 | // mapList.add(map); 261 | // } 262 | // JdbcUtils2.update(connection, "sensitive_word", mapList, "serviceKind", "sensitive_word"); 263 | // 264 | // //用完数据库,释放连接 265 | // JdbcUtils2.free(null,null,connection); 266 | 267 | 268 | 269 | 270 | 271 | // Connection connection = JdbcUtils2.getConnection("jdbc:mysql://localhost:3306/song?characterEncoding=UTF8", 272 | // "root", "465864") ; 273 | // for (int i = 1; i < 81; i++) { 274 | // File file = new File("C:\\Users\\Lifeix\\Desktop\\歌词\\" + i + ".txt"); 275 | // String[] strs = readTxtByLine(file,"utf-8"); 276 | // 277 | // String sql1 = "insert into track(tid, trackname, singername) values (?,?,?)" ; 278 | // JdbcUtils2.insert(connection, sql1, i+"" ,strs[0], strs[1] + strs[2]); 279 | // 280 | // String sql2 = "insert into lyrics(tid, lrc) values (?,?)" ; 281 | // StringBuilder s = new StringBuilder(); 282 | // for (int j = 3; j < strs.length; j++) { 283 | // s.append(strs[j]); 284 | // } 285 | // JdbcUtils2.insert(connection, sql2, i+"" ,s.toString()); 286 | // } 287 | // 288 | // 289 | // //用完数据库,释放连接 290 | // JdbcUtils2.free(null,null,connection); 291 | } 292 | } 293 | -------------------------------------------------------------------------------- /src/main/java/com/lifeix/robot/vo/AccountContentVO.java: -------------------------------------------------------------------------------- 1 | package com.lifeix.robot.vo; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created by lhx on 15-2-6 下午6:49 8 | * 9 | * @project point-like-robot 10 | * @package com.lifeix.robot.vo 11 | * @Description 12 | * @blog http://blog.csdn.net/u011439289 13 | * @email 888xin@sina.com 14 | * @github https://github.com/888xin 15 | */ 16 | public class AccountContentVO implements Serializable { 17 | 18 | private long dashboardId ; 19 | private long accountId ; 20 | private int pointedGender ; 21 | private Date createTime ; 22 | private boolean status ; 23 | 24 | public long getDashboardId() { 25 | return dashboardId; 26 | } 27 | 28 | public void setDashboardId(long dashboardId) { 29 | this.dashboardId = dashboardId; 30 | } 31 | 32 | public long getAccountId() { 33 | return accountId; 34 | } 35 | 36 | public void setAccountId(long accountId) { 37 | this.accountId = accountId; 38 | } 39 | 40 | public int getPointedGender() { 41 | return pointedGender; 42 | } 43 | 44 | public void setPointedGender(int pointedGender) { 45 | this.pointedGender = pointedGender; 46 | } 47 | 48 | public Date getCreateTime() { 49 | return createTime; 50 | } 51 | 52 | public void setCreateTime(Date createTime) { 53 | this.createTime = createTime; 54 | } 55 | 56 | public boolean isStatus() { 57 | return status; 58 | } 59 | 60 | public void setStatus(boolean status) { 61 | this.status = status; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/resources/application.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 120 | 121 | 122 | 123 | 124 | 0 0/1 * * * ? 125 | 126 | 127 | 128 | 129 | 130 | 132 | 133 | 134 | 135 | 136 | work 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /src/main/resources/jdbc.properties: -------------------------------------------------------------------------------- 1 | jdbc.driver=com.mysql.jdbc.Driver 2 | jdbc.initialPoolSize=10 3 | jdbc.minPoolSize=10 4 | jdbc.maxPoolSize=20 5 | jdbc.maxIdleTime=2000 6 | jdbc.acquireIncrement=5 7 | jdbc.acquireCheckoutTimeout=3000 8 | jdbc.url=jdbc:mysql://localhost:3306/test?characterEncoding=UTF8 9 | jdbc.username=root 10 | jdbc.password=465864 11 | 12 | mongo.db.host=localhost 13 | mongo.db.port=27017 14 | mongo.db.database=test2014 -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ### set log levels ### 2 | #log4j.rootLogger = debug , stdout , D , E 3 | log4j.rootLogger = info, debug , stdout , D 4 | 5 | ### output to the console ### 6 | log4j.appender.stdout = org.apache.log4j.ConsoleAppender 7 | log4j.appender.stdout.Target = System.out 8 | log4j.appender.stdout.layout = org.apache.log4j.PatternLayout 9 | #log4j.appender.stdout.layout.ConversionPattern = %d{ABSOLUTE} %5p %c{ 1 }:%L - %m%n 10 | log4j.appender.stdout.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n 11 | 12 | ### Output to the log file ### 13 | log4j.appender.D = org.apache.log4j.DailyRollingFileAppender 14 | log4j.appender.D.File = ${springmvc.root}/WEB-INF/logs/log.log 15 | log4j.appender.D.Append = true 16 | log4j.appender.D.Threshold = DEBUG 17 | log4j.appender.D.layout = org.apache.log4j.PatternLayout 18 | log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n 19 | 20 | ### Save exception information to separate file ### 21 | log4j.appender.D = org.apache.log4j.DailyRollingFileAppender 22 | log4j.appender.D.File = ${springmvc.root}/WEB-INF/logs/error.log 23 | log4j.appender.D.Append = true 24 | log4j.appender.D.Threshold = ERROR 25 | log4j.appender.D.layout = org.apache.log4j.PatternLayout 26 | log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n -------------------------------------------------------------------------------- /src/main/resources/mapper/PointLikeAccountDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | insert into point_like_account(point_accountId,point_gender) 9 | values 10 | (#{pointAccountId},#{pointGender}) 11 | 12 | 13 | 17 | 18 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PointLikeAccountDetailDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | insert into point_like_account_detail(id,point_accountId,point_gender,pointed_accountId,pointed_gender,point_time,remark,dashboardId,like_expression) 9 | values 10 | (#{id},#{pointAccountId},#{pointGender},#{pointedAccountId},#{pointedGender},#{pointTime},#{remark},#{dashboardId},#{likeExpression}) 11 | 12 | 13 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/resources/mongodb.properties: -------------------------------------------------------------------------------- 1 | db.host=localhost 2 | db.port=27017 3 | db.database=test2014 4 | #db.username=marker 5 | #db.password=123 -------------------------------------------------------------------------------- /src/main/resources/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | text/html;charset=UTF-8 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /src/main/resources/spring-mybatis.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 24 | 25 | com.mysql.jdbc.Driver 26 | 27 | 28 | jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8 29 | 30 | 31 | root 32 | 33 | 34 | 465864 35 | 36 | 37 | 38 | 20 39 | 40 | 41 | 42 | 1 43 | 44 | 45 | 46 | 60000 47 | 48 | 49 | 50 | 20 51 | 52 | 53 | 54 | 3 55 | 56 | 57 | 58 | true 59 | 60 | 61 | 62 | 180 63 | 64 | 65 | 66 | clientEncoding=UTF-8 67 | 68 | 69 | 70 | 71 | 75 | 76 | 77 | 80 | 81 | 82 | 85 | -------------------------------------------------------------------------------- /src/test/java/com/lifeix/test/MyTest.java: -------------------------------------------------------------------------------- 1 | package com.lifeix.test; 2 | 3 | import com.lifeix.robot.dao.PointLikeAccountDao; 4 | import com.lifeix.robot.dao.PointLikeAccountDetailDao; 5 | import com.lifeix.robot.model.PointLikeAccount; 6 | import com.lifeix.robot.model.PointLikeAccountDetail; 7 | import com.lifeix.robot.mongo.PointLikeAccountMongoService; 8 | import com.lifeix.robot.vo.AccountContentVO; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.springframework.context.ApplicationContext; 12 | import org.springframework.context.support.ClassPathXmlApplicationContext; 13 | import org.springframework.data.mongodb.core.MongoTemplate; 14 | import org.springframework.data.mongodb.core.query.Criteria; 15 | import org.springframework.data.mongodb.core.query.Query; 16 | import org.springframework.data.mongodb.core.query.Update; 17 | 18 | import java.util.Calendar; 19 | import java.util.Date; 20 | import java.util.List; 21 | 22 | /** 23 | * Created by xin on 15-2-7 上午10:45 24 | * 25 | * @project pointlikerobot 26 | * @package com.lifeix.test 27 | * @Description 28 | * @blog http://blog.csdn.net/u011439289 29 | * @email 888xin@sina.com 30 | * @github https://github.com/888xin 31 | */ 32 | 33 | public class MyTest { 34 | 35 | private PointLikeAccountDao pointLikeAccountDao ; 36 | private PointLikeAccountDetailDao pointLikeAccountDetailDao ; 37 | private MongoTemplate mongoTemplate; 38 | 39 | 40 | @Before 41 | public void before(){ 42 | @SuppressWarnings("resource") 43 | ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"classpath:application.xml" 44 | ,"classpath:spring-mybatis.xml"}); 45 | pointLikeAccountDao = (PointLikeAccountDao) context.getBean("pointLikeAccountDao"); 46 | pointLikeAccountDetailDao = (PointLikeAccountDetailDao) context.getBean("pointLikeAccountDetailDao"); 47 | mongoTemplate = (MongoTemplate) context.getBean("mongoTemplate"); 48 | } 49 | 50 | /** 51 | * ============================================================== 52 | */ 53 | 54 | @Test 55 | public void testinsertPraiseUser(){ 56 | PointLikeAccount pointLikeAccount = new PointLikeAccount(); 57 | pointLikeAccount.setPointGender(1); 58 | pointLikeAccount.setPointAccountId(254234L); 59 | System.out.println(pointLikeAccountDao.insertpointLikeAccount(pointLikeAccount)); 60 | } 61 | 62 | @Test 63 | public void testgetPraiseUser(){ 64 | List list = pointLikeAccountDao.getpointLikeAccounts(1); 65 | System.out.println(list); 66 | } 67 | 68 | /** 69 | * ============================================================== 70 | */ 71 | 72 | @Test 73 | public void testinsertPointLikeAccount(){ 74 | PointLikeAccountDetail pointLikeAccountDetail = new PointLikeAccountDetail(); 75 | pointLikeAccountDetail.setId(1100L); 76 | pointLikeAccountDetail.setPointAccountId(2L); 77 | pointLikeAccountDetail.setPointedAccountId(3L); 78 | pointLikeAccountDetail.setPointedGender(1); 79 | pointLikeAccountDetail.setPointGender(0); 80 | pointLikeAccountDetail.setDashboardId(34444L); 81 | pointLikeAccountDetail.setLikeExpression(2); 82 | pointLikeAccountDetail.setPointTime(new Date()); 83 | pointLikeAccountDetail.setRemark("测试"); 84 | System.out.println(pointLikeAccountDetailDao.insertPointLikeAccountDetail(pointLikeAccountDetail)); 85 | } 86 | 87 | /** 88 | * ============================= 89 | */ 90 | 91 | @Test 92 | public void testmongoTemplate(){ 93 | AccountContentVO accountContentVO = new AccountContentVO(); 94 | accountContentVO.setAccountId(15L); 95 | accountContentVO.setDashboardId(1008L); 96 | accountContentVO.setStatus(false); 97 | accountContentVO.setPointedGender(1); 98 | accountContentVO.setCreateTime(new Date()); 99 | mongoTemplate.insert(accountContentVO,"accountcontent"); 100 | } 101 | 102 | @Test 103 | public void testmongoupdate(){ 104 | mongoTemplate.upsert(new Query(Criteria.where("dashboardId").is(32L)), Update.update("status", true), "accountcontent"); 105 | } 106 | 107 | @Test 108 | public void testgetByTime(){ 109 | //现在的时间 110 | Date currentTime = new Date(); 111 | //minutes分钟前 112 | Calendar cal = Calendar.getInstance(); 113 | cal.add(Calendar.MINUTE, -10); 114 | Date end = cal.getTime(); 115 | Query query = new Query(); 116 | Criteria criteria = Criteria.where("createTime").gte(end).lte(currentTime); 117 | query.addCriteria(criteria); 118 | List list = mongoTemplate.find(query, AccountContentVO.class, "accountcontent"); 119 | } 120 | 121 | @Test 122 | public void testgetByNumbers(){ 123 | List list = mongoTemplate.find(new Query(Criteria.where("status").is(true)).limit(2), AccountContentVO.class, "accountcontent"); 124 | } 125 | 126 | // @Test 127 | // public void testjson(){ 128 | // JSONObject json = JSON.parseObject("{\"dashboardId\":6787578,\"accountId\":1000,\"createTime\":\"2015-12-12 12:35:123\"}"); 129 | // System.out.println(json.get("dashboardId")); 130 | // } 131 | } 132 | -------------------------------------------------------------------------------- /web/WEB-INF/errorpage/404.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: Lifeix 4 | Date: 14-12-22 5 | Time: 下午3:05 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /web/WEB-INF/errorpage/405.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: Lifeix 4 | Date: 14-12-22 5 | Time: 下午3:05 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /web/WEB-INF/errorpage/500.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: Lifeix 4 | Date: 14-12-22 5 | Time: 下午3:06 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /web/WEB-INF/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: Lifeix 4 | Date: 14-12-22 5 | Time: 下午3:07 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 |

欢迎你!!!

15 | 16 | 17 | -------------------------------------------------------------------------------- /web/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | contextConfigLocation 11 | classpath:application.xml; 12 | classpath:spring-mybatis.xml 13 | 14 | 15 | 16 | 17 | webAppRootKey 18 | springmvc.root 19 | 20 | 21 | 22 | 23 | SpringEncodingFilter 24 | org.springframework.web.filter.CharacterEncodingFilter 25 | 26 | encoding 27 | UTF-8 28 | 29 | 30 | forceEncoding 31 | true 32 | 33 | 34 | 35 | SpringEncodingFilter 36 | /* 37 | 38 | 39 | 40 | 41 | 42 | log4jConfigLocation 43 | classpath:log4j.properties 44 | 45 | 46 | 47 | log4jRefreshInterval 48 | 6000 49 | 50 | 51 | org.springframework.web.util.Log4jConfigListener 52 | 53 | 54 | 55 | org.springframework.web.context.ContextLoaderListener 56 | 57 | 58 | 59 | 60 | spring 61 | org.springframework.web.servlet.DispatcherServlet 62 | 63 | contextConfigLocation 64 | classpath:spring-mvc.xml 65 | 66 | 2 67 | 68 | 69 | spring 70 | *.do 71 | 72 | 73 | 74 | 75 | 76 | 404 77 | /WEB-INF/errorpage/404.jsp 78 | 79 | 80 | 81 | 405 82 | /WEB-INF/errorpage/405.jsp 83 | 84 | 85 | 86 | 500 87 | /WEB-INF/errorpage/500.jsp 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /web/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: xin 4 | Date: 15-2-7 5 | Time: 下午12:35 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | --------------------------------------------------------------------------------