新闻推送相关
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
package com.fangjia.job.youfang.document;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 城市相关推送记录
|
||||
*
|
||||
* @author user
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class CitySendLog {
|
||||
|
||||
private String city;
|
||||
|
||||
private long uid;
|
||||
|
||||
private long newsId;
|
||||
|
||||
private Date sendTime;
|
||||
|
||||
/*
|
||||
* 0.置顶咨询推送,1.小区推送 2.涨幅排行推送 3.跌幅排行推送 4.潜力排行推送
|
||||
*/
|
||||
private byte sendType;
|
||||
|
||||
}
|
||||
+12
@@ -2,13 +2,25 @@ package com.fangjia.job.youfang.job;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.dangdang.ddframe.job.api.ShardingContext;
|
||||
import com.dangdang.ddframe.job.api.simple.SimpleJob;
|
||||
import com.fangjia.job.youfang.service.CityCollectService;
|
||||
import com.fangjia.job.youfang.service.CitySendLogService;
|
||||
import com.fangjia.job.youfang.service.PushMessageService;
|
||||
import com.fangjia.job.youfang.service.PushRecordMessageService;
|
||||
|
||||
public class CityRankingSendJob implements SimpleJob {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TopNewsSendJob.class);
|
||||
|
||||
@Autowired
|
||||
private CityCollectService cityCollectService;
|
||||
|
||||
@Autowired
|
||||
private CitySendLogService citySendLogService;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(ShardingContext context) {
|
||||
|
||||
+16
-1
@@ -2,14 +2,29 @@ package com.fangjia.job.youfang.job;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.dangdang.ddframe.job.api.ShardingContext;
|
||||
import com.dangdang.ddframe.job.api.simple.SimpleJob;
|
||||
import com.fangjia.job.youfang.service.CityCollectService;
|
||||
import com.fangjia.job.youfang.service.CitySendLogService;
|
||||
import com.fangjia.job.youfang.service.NewsService;
|
||||
import com.fangjia.job.youfang.service.PushMessageService;
|
||||
import com.fangjia.job.youfang.service.PushRecordMessageService;
|
||||
|
||||
public class HousingEstateNewsSendJob implements SimpleJob {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TopNewsSendJob.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private CityCollectService cityCollectService;
|
||||
|
||||
@Autowired
|
||||
private CitySendLogService citySendLogService;
|
||||
|
||||
@Autowired
|
||||
private NewsService newsService;
|
||||
|
||||
@Override
|
||||
public void execute(ShardingContext context) {
|
||||
LOG.info("城市小区推送开始,context:"+context);
|
||||
|
||||
+15
@@ -2,13 +2,28 @@ package com.fangjia.job.youfang.job;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.dangdang.ddframe.job.api.ShardingContext;
|
||||
import com.dangdang.ddframe.job.api.simple.SimpleJob;
|
||||
import com.fangjia.job.youfang.service.CityCollectService;
|
||||
import com.fangjia.job.youfang.service.CitySendLogService;
|
||||
import com.fangjia.job.youfang.service.NewsService;
|
||||
import com.fangjia.job.youfang.service.PushMessageService;
|
||||
import com.fangjia.job.youfang.service.PushRecordMessageService;
|
||||
|
||||
public class TopNewsSendJob implements SimpleJob {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TopNewsSendJob.class);
|
||||
|
||||
@Autowired
|
||||
private CityCollectService cityCollectService;
|
||||
|
||||
@Autowired
|
||||
private CitySendLogService citySendLogService;
|
||||
|
||||
@Autowired
|
||||
private NewsService newsService;
|
||||
|
||||
@Override
|
||||
public void execute(ShardingContext context) {
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ public class CityCollect implements Serializable {
|
||||
|
||||
@AutoId
|
||||
@Field(value = "id", desc = "ID")
|
||||
private long id;
|
||||
private Long id;
|
||||
|
||||
@Field(value = "city", desc = "城市")
|
||||
private String city;
|
||||
@@ -25,5 +25,5 @@ public class CityCollect implements Serializable {
|
||||
private Data addTime;
|
||||
|
||||
@Field(value = "uid", desc = "用户ID")
|
||||
private long uid;
|
||||
private Long uid;
|
||||
}
|
||||
|
||||
+153
-9
@@ -50,8 +50,8 @@ public class News implements Serializable {
|
||||
@Field(value = "content", desc = "内容")
|
||||
private String content;
|
||||
|
||||
@Field(value = "publish_status", desc = "是否已发布(0:未发布,1已发布)")
|
||||
private int publishStatus;
|
||||
// @Field(value = "publish_status", desc = "是否已发布(0:未发布,1已发布)")
|
||||
// private int publishStatus;
|
||||
|
||||
@Field(value = "top_status", desc = "是否置顶(0否 1是)")
|
||||
private int topStatus;
|
||||
@@ -62,6 +62,9 @@ public class News implements Serializable {
|
||||
@Field(value = "visit_count", desc = "浏览量")
|
||||
private int visitCount;
|
||||
|
||||
@Field(value = "thumbs_up_count", desc = "点赞量")
|
||||
private int thumbsUpCount;
|
||||
|
||||
@Field(value = "vote_favor_count", desc = "投票赞成数量")
|
||||
private int voteFavorCount;
|
||||
|
||||
@@ -71,6 +74,42 @@ public class News implements Serializable {
|
||||
@Field(value = "user_id", desc = "创建用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Field(value = "m_date", desc = "修改时间")
|
||||
private Date mDate;
|
||||
|
||||
@Field(value = "tags", desc = "标签,多个下划线分割")
|
||||
private String tags;
|
||||
|
||||
@Field(value = "vote_favor_text", desc = "投票赞成显示文字(投票类专有)")
|
||||
private String voteFavorText;
|
||||
|
||||
@Field(value = "vote_no_favor_text", desc = "投票不赞成显示文字(投票类专有)")
|
||||
private String voteNoFavorText;
|
||||
|
||||
@Field(value = "recommend_city", desc = "推荐城市,城市推荐才有此值")
|
||||
private String recommendCity;
|
||||
|
||||
@Field(value = "recommend_city_tags", desc = "推荐城市的标签,下划线分割,城市推荐才有此值")
|
||||
private String recommendCityTags;
|
||||
|
||||
@Field(value = "recommend_district_city", desc = "小区推荐咨询的城市")
|
||||
private String recommendDistrictCity;
|
||||
|
||||
@Field(value = "recommend_district_region", desc = "小区推荐咨询的区域")
|
||||
private String recommendDistrictRegion;
|
||||
|
||||
@Field(value = "recommend_district_name", desc = "小区推荐咨询的小区名")
|
||||
private String recommendDistrictName;
|
||||
|
||||
@Field(value = "recommend_district_tags", desc = "小区推荐咨询的小区标签,下划线分割")
|
||||
private String recommendDistrictTags;
|
||||
|
||||
@Field(value = "small_cover_img", desc = "封面缩略图")
|
||||
private String smallCoverImg;
|
||||
|
||||
@Field(value = "init_visit_count", desc = "初始化浏览量")
|
||||
private Integer initVisitCount;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -175,13 +214,13 @@ public class News implements Serializable {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public int getPublishStatus() {
|
||||
return publishStatus;
|
||||
}
|
||||
|
||||
public void setPublishStatus(int publishStatus) {
|
||||
this.publishStatus = publishStatus;
|
||||
}
|
||||
// public int getPublishStatus() {
|
||||
// return publishStatus;
|
||||
// }
|
||||
//
|
||||
// public void setPublishStatus(int publishStatus) {
|
||||
// this.publishStatus = publishStatus;
|
||||
// }
|
||||
|
||||
public int getTopStatus() {
|
||||
return topStatus;
|
||||
@@ -230,4 +269,109 @@ public class News implements Serializable {
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getThumbsUpCount() {
|
||||
return thumbsUpCount;
|
||||
}
|
||||
|
||||
public void setThumbsUpCount(int thumbsUpCount) {
|
||||
this.thumbsUpCount = thumbsUpCount;
|
||||
}
|
||||
|
||||
public Date getmDate() {
|
||||
return mDate;
|
||||
}
|
||||
|
||||
public void setmDate(Date mDate) {
|
||||
this.mDate = mDate;
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(String tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public String getVoteFavorText() {
|
||||
return voteFavorText;
|
||||
}
|
||||
|
||||
public void setVoteFavorText(String voteFavorText) {
|
||||
this.voteFavorText = voteFavorText;
|
||||
}
|
||||
|
||||
public String getVoteNoFavorText() {
|
||||
return voteNoFavorText;
|
||||
}
|
||||
|
||||
public void setVoteNoFavorText(String voteNoFavorText) {
|
||||
this.voteNoFavorText = voteNoFavorText;
|
||||
}
|
||||
|
||||
public String getRecommendCity() {
|
||||
return recommendCity;
|
||||
}
|
||||
|
||||
public void setRecommendCity(String recommendCity) {
|
||||
this.recommendCity = recommendCity;
|
||||
}
|
||||
|
||||
public String getRecommendCityTags() {
|
||||
return recommendCityTags;
|
||||
}
|
||||
|
||||
public void setRecommendCityTags(String recommendCityTags) {
|
||||
this.recommendCityTags = recommendCityTags;
|
||||
}
|
||||
|
||||
public String getRecommendDistrictCity() {
|
||||
return recommendDistrictCity;
|
||||
}
|
||||
|
||||
public void setRecommendDistrictCity(String recommendDistrictCity) {
|
||||
this.recommendDistrictCity = recommendDistrictCity;
|
||||
}
|
||||
|
||||
public String getRecommendDistrictRegion() {
|
||||
return recommendDistrictRegion;
|
||||
}
|
||||
|
||||
public void setRecommendDistrictRegion(String recommendDistrictRegion) {
|
||||
this.recommendDistrictRegion = recommendDistrictRegion;
|
||||
}
|
||||
|
||||
public String getRecommendDistrictName() {
|
||||
return recommendDistrictName;
|
||||
}
|
||||
|
||||
public void setRecommendDistrictName(String recommendDistrictName) {
|
||||
this.recommendDistrictName = recommendDistrictName;
|
||||
}
|
||||
|
||||
public String getRecommendDistrictTags() {
|
||||
return recommendDistrictTags;
|
||||
}
|
||||
|
||||
public void setRecommendDistrictTags(String recommendDistrictTags) {
|
||||
this.recommendDistrictTags = recommendDistrictTags;
|
||||
}
|
||||
|
||||
public String getSmallCoverImg() {
|
||||
return smallCoverImg;
|
||||
}
|
||||
|
||||
public void setSmallCoverImg(String smallCoverImg) {
|
||||
this.smallCoverImg = smallCoverImg;
|
||||
}
|
||||
|
||||
public Integer getInitVisitCount() {
|
||||
return initVisitCount;
|
||||
}
|
||||
|
||||
public void setInitVisitCount(Integer initVisitCount) {
|
||||
this.initVisitCount = initVisitCount;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-6
@@ -17,7 +17,7 @@ public class PushMessage implements Serializable {
|
||||
|
||||
@AutoId
|
||||
@Field(value = "id", desc = "ID")
|
||||
private long id;
|
||||
private Long id;
|
||||
|
||||
@Field(value = "title", desc = "标题")
|
||||
private String title;
|
||||
@@ -29,16 +29,16 @@ public class PushMessage implements Serializable {
|
||||
private Date addTime;
|
||||
|
||||
@Field(value = "save_status", desc = "用户消息列表是否留存(0不存,1存)")
|
||||
private int saveStatus;
|
||||
private Integer saveStatus;
|
||||
|
||||
@Field(value = "operation", desc = "通知操作(0:打开应用,1:打开指定页面,2:打开url)")
|
||||
private int operation;
|
||||
private Integer operation;
|
||||
|
||||
@Field(value = "operation_page", desc = "当通知操作为打开具体页面时这个值就是页面的值,当为打开url时这个值就是url的值")
|
||||
private String operationPage;
|
||||
|
||||
@Field(value = "user_range", desc = "通知用户范围(0:全部用户,1:部分用户)")
|
||||
private int userRange;
|
||||
private Integer userRange;
|
||||
|
||||
@Field(value = "user_range_city", desc = "通知用户范围对应的城市")
|
||||
private String userRangeCity;
|
||||
@@ -47,13 +47,13 @@ public class PushMessage implements Serializable {
|
||||
private Date pushTime;
|
||||
|
||||
@Field(value = "push_status", desc = "是否已推送(0未推送,1已推送)")
|
||||
private int pushStatus;
|
||||
private Integer pushStatus;
|
||||
|
||||
@Field(value = "user_range_province", desc = "通知用户所在省份")
|
||||
private String userRangeProvince;
|
||||
|
||||
@Field(value = "uid", desc = "创建用户ID")
|
||||
private long uid;
|
||||
private Long uid;
|
||||
|
||||
@Field(value = "user_range_city_code", desc = "个推城市码")
|
||||
private String userRangeCityCode;
|
||||
|
||||
+4
-4
@@ -17,17 +17,17 @@ public class PushRecordMessage implements Serializable {
|
||||
|
||||
@AutoId
|
||||
@Field(value = "id", desc = "ID")
|
||||
private long id;
|
||||
private Long id;
|
||||
|
||||
@Field(value = "uid", desc = "用户ID")
|
||||
private long uid;
|
||||
private Long uid;
|
||||
|
||||
@Field(value = "mid", desc = "消息ID")
|
||||
private long mid;
|
||||
private Long mid;
|
||||
|
||||
@Field(value = "add_time", desc = "添加时间")
|
||||
private Date addTime;
|
||||
|
||||
@Field(value = "read_status", desc = "是否已读 (0未读,1已读)")
|
||||
private int readStatus;
|
||||
private Integer readStatus;
|
||||
}
|
||||
|
||||
+6
-4
@@ -5,16 +5,18 @@ import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
import com.fangjia.job.youfang.po.AdVisitLog;
|
||||
import com.cxytiandi.jdbc.Orders;
|
||||
import com.cxytiandi.jdbc.Orders.OrderyType;
|
||||
import com.fangjia.job.youfang.po.CityCollect;
|
||||
|
||||
@Service
|
||||
public class CityCollectServiceImpl extends EntityService<AdVisitLog> implements CityCollectService {
|
||||
public class CityCollectServiceImpl extends EntityService<CityCollect> implements CityCollectService {
|
||||
|
||||
private static final String ORDER_PARAM = "city";
|
||||
|
||||
@Override
|
||||
public List<CityCollect> findAll() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return super.list(new Orders[] { new Orders(ORDER_PARAM, OrderyType.ASC) });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.fangjia.job.youfang.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.job.youfang.document.CitySendLog;
|
||||
|
||||
public interface CitySendLogService {
|
||||
|
||||
void save(CitySendLog log);
|
||||
|
||||
List<CitySendLog> find(long uid, Long newsId, Byte sendType);
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.fangjia.job.youfang.service;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fangjia.job.youfang.document.CitySendLog;
|
||||
|
||||
@Service
|
||||
public class CitySendLogServiceImpl implements CitySendLogService {
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public void save(CitySendLog log) {
|
||||
mongoTemplate.save(log);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CitySendLog> find(long uid, Long newsId, Byte sendType) {
|
||||
if (null != newsId) {// 咨询推送
|
||||
Query query = Query.query(Criteria.where("uid").is(uid).and("newsId").is(newsId));
|
||||
return mongoTemplate.find(query, CitySendLog.class);
|
||||
} else { // 排名推送,查当前一个月内的记录
|
||||
Query query = Query.query(
|
||||
Criteria.where("uid").is(uid).and("sendTime").gt(getMonthAgo()).and("sendType").is(sendType));
|
||||
return mongoTemplate.find(query, CitySendLog.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取一个月前的时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Date getMonthAgo() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(new Date());
|
||||
c.add(Calendar.MONTH, -1);
|
||||
return c.getTime();
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -1,19 +1,28 @@
|
||||
package com.fangjia.job.youfang.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.job.youfang.po.News;
|
||||
|
||||
public interface NewsService {
|
||||
|
||||
/**
|
||||
* 发布新闻
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
void pushNews(String date);
|
||||
|
||||
|
||||
/**
|
||||
* 下架新闻
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
void offlineNews(String date);
|
||||
|
||||
|
||||
List<News> findTopNews(String city);
|
||||
|
||||
List<News> findHousingEstate(String city);
|
||||
}
|
||||
|
||||
+24
-2
@@ -1,5 +1,7 @@
|
||||
package com.fangjia.job.youfang.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
@@ -8,16 +10,36 @@ import com.fangjia.job.youfang.po.News;
|
||||
@Service
|
||||
public class NewsServiceImpl extends EntityService<News> implements NewsService {
|
||||
|
||||
private static final int TOP_STATUS = 1;
|
||||
|
||||
private static final int ON_LINE_STATUS = 1;
|
||||
|
||||
private static final String NEWS_TYPE = "新闻";
|
||||
|
||||
private static final String HOUSING_ESTATE_TYPE = "推荐小区";
|
||||
|
||||
@Override
|
||||
public void pushNews(String date) {
|
||||
String sql = "update news set `status`=1 where `status`=0 and deploy_time<='"+date+"'";
|
||||
String sql = "update news set `status`=1 where `status`=0 and deploy_time<='" + date + "'";
|
||||
super.getJdbcTemplate().execute(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void offlineNews(String date) {
|
||||
String sql = "update news set `status`=2 where `status`=1 and offline_time<='"+date+"'";
|
||||
String sql = "update news set `status`=2 where `status`=1 and offline_time<='" + date + "'";
|
||||
super.getJdbcTemplate().execute(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<News> findTopNews(String city) {
|
||||
return super.list(new String[] { "status", "top_status", "type", "city" },
|
||||
new Object[] { ON_LINE_STATUS, TOP_STATUS, NEWS_TYPE, city });
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<News> findHousingEstate(String city) {
|
||||
return super.list(new String[] { "status", "type", "city" },
|
||||
new Object[] { ON_LINE_STATUS, HOUSING_ESTATE_TYPE, city });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-4
@@ -1,8 +1,5 @@
|
||||
package com.fangjia.job.youfang.service;
|
||||
|
||||
import com.fangjia.job.youfang.po.PushMessage;
|
||||
|
||||
public interface PushMessageService {
|
||||
|
||||
void insert(PushMessage message);
|
||||
|
||||
}
|
||||
|
||||
-6
@@ -8,10 +8,4 @@ import com.fangjia.job.youfang.po.PushMessage;
|
||||
@Service
|
||||
public class PushMessageServiceImpl extends EntityService<PushMessage> implements PushMessageService {
|
||||
|
||||
@Override
|
||||
public void insert(PushMessage message) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-5
@@ -1,10 +1,5 @@
|
||||
package com.fangjia.job.youfang.service;
|
||||
|
||||
import com.fangjia.job.youfang.po.PushRecordMessage;
|
||||
|
||||
public interface PushRecordMessageService {
|
||||
|
||||
PushRecordMessage findByUidAndMid(long uid,long mid);
|
||||
|
||||
void insert(PushRecordMessage message);
|
||||
}
|
||||
|
||||
-13
@@ -3,22 +3,9 @@ package com.fangjia.job.youfang.service;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
import com.fangjia.job.youfang.po.AdVisitLog;
|
||||
import com.fangjia.job.youfang.po.PushRecordMessage;
|
||||
|
||||
@Service
|
||||
public class PushRecordMessageServiceImpl extends EntityService<PushRecordMessage> implements PushRecordMessageService {
|
||||
|
||||
@Override
|
||||
public PushRecordMessage findByUidAndMid(long uid, long mid) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(PushRecordMessage message) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user