Authored by liangyi.chen@yoho.cn

爬虫数据更新

... ... @@ -35,6 +35,29 @@ public class TblCrawlerArticleController {
return new ApiResponse.ApiResponseBuilder().build();
}
@RequestMapping("/tblTimerPublish")
public ApiResponse tblTimerPublish(TbleCrawlerAddToGrassReq req){
logger.info("tblCrawlerArticle timerPublish begin, req is {}",req);
try {
tblCrawlerInfoService.timerPublishToGrass(req);
} catch (PlatformException e) {
return new ApiResponse.ApiResponseBuilder().code(e.getCode()).message(e.getMessage()).build();
}
return new ApiResponse.ApiResponseBuilder().build();
}
@RequestMapping("/saveTblArticleDraft")
public ApiResponse saveTblArticleDraft(TbleCrawlerAddToGrassReq req){
logger.info("tblCrawlerArticle saveTblArticleDraft begin, req is {}", req);
try {
req.setAuthStatus(9);
tblCrawlerInfoService.addToGrassArticle(req);
} catch (PlatformException e) {
return new ApiResponse.ApiResponseBuilder().code(e.getCode()).message(e.getMessage()).build();
}
return new ApiResponse.ApiResponseBuilder().build();
}
@RequestMapping("/queryTblCrawlerArticle")
public ApiResponse queryTblCrawlerArticle(TblCrawlerInfoQueryReq req){
logger.info("tblCrawlerArticle queryTblCrawlerArticle begin, req is {}",req);
... ...
... ... @@ -28,7 +28,7 @@ public interface IGrassArticleService {
void deleteArticle(GrassArticleReq req) throws PlatformException;
void timerPublish(GrassArticleReq req) throws PlatformException;
Integer timerPublish(GrassArticleReq req) throws PlatformException;
ArticleDetailRspBo getArticleById(GrassArticleReq req) throws PlatformException;
... ...
... ... @@ -15,5 +15,7 @@ public interface ITblCrawlerInfoService {
void addToGrassArticle(TbleCrawlerAddToGrassReq req) throws PlatformException;
void timerPublishToGrass(TbleCrawlerAddToGrassReq req) throws PlatformException;
TblCrawlerInfoQueryRsp queryTblCrawlerInfoById(Integer id);
}
... ...
... ... @@ -129,6 +129,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
article.setAuthorUid(req.getAuthorUid());
article.setCreateTime(now);
article.setAuthStatus(req.getAuthStatus());
article.setArticleType(req.getArticleType());
article.setAuthTime(System.currentTimeMillis());
try{
grassArticleDao.insertArticleSeletive(article);
... ... @@ -876,7 +877,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
@Override
@Database(ForceMaster = true)
public void timerPublish(GrassArticleReq req) throws PlatformException {
public Integer timerPublish(GrassArticleReq req) throws PlatformException {
logger.info("enter timerPublish, req is {}", req);
publishCheck(req);
... ... @@ -911,6 +912,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
article.setCreateTime(time);
article.setAuthStatus(1);
article.setAuthTime(time);
article.setArticleType(req.getArticleType());
try{
grassArticleDao.insertArticleSeletive(article);
logger.info("insert grass article success, uid is {}, ariticle id is {}", article.getAuthorUid(), article.getId());
... ... @@ -1015,7 +1017,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
grassArticleLabel.setCreateTime(time);
grassArticleLabelDao.updateByPrimaryKeySelective(grassArticleLabel);
logger.info("timerPublish updateByPrimaryKeySelective success! id={}",articleId);
return articleId;
}
/**
... ...
... ... @@ -223,15 +223,43 @@ public class TblCrawlerInfoServiceImpl implements ITblCrawlerInfoService {
throw new PlatformException("当前爬虫数据已被发布过",405);
}
//发布到种草文章表
req.setArticleType(ArticleTypeEnum.TBLCRAWLER.getValue());
Integer articleId = grassArticleService.publishArticle(req);
//维护爬虫数据和种草文章关联关系
TblCrawlerArticleRelation tblCrawlerArticleRelation = new TblCrawlerArticleRelation();
tblCrawlerArticleRelation.setRelateId(articleId);
tblCrawlerArticleRelation.setArticleType((byte) ArticleTypeEnum.NORMAL.getValue());
tblCrawlerArticleRelation.setCrawlerId(req.getCrawlerId());
tblCrawlerArticleRelation.setCreateTime(System.currentTimeMillis());
//维护爬虫数据和种草文章关联关系(草稿箱不用维护)
if(req.getAuthStatus() != 9){
TblCrawlerArticleRelation tblCrawlerArticleRelation = new TblCrawlerArticleRelation();
tblCrawlerArticleRelation.setRelateId(articleId);
tblCrawlerArticleRelation.setArticleType((byte) ArticleTypeEnum.TBLCRAWLER.getValue());
tblCrawlerArticleRelation.setCrawlerId(req.getCrawlerId());
tblCrawlerArticleRelation.setCreateTime(System.currentTimeMillis());
}
}
/**
* 爬虫数据内容定时发布到种草文章
* @param req
* @throws PlatformException
*/
@Override
public void timerPublishToGrass(TbleCrawlerAddToGrassReq req) throws PlatformException {
//校验当前爬虫数据是否已经在种草或者mars发布过,如果是则不能二次编辑和发布
List<TblCrawlerArticleRelation> relationList = tblCrawlerArticleRelationDao.selectByCrawlerId(req.getCrawlerId());
if(!relationList.isEmpty()){
throw new PlatformException("当前爬虫数据已被发布过",405);
}
//发布到种草文章表
req.setArticleType(ArticleTypeEnum.TBLCRAWLER.getValue());
Integer articleId = grassArticleService.timerPublish(req);
//维护爬虫数据和种草文章关联关系(草稿箱不用维护)
if(req.getAuthStatus() != 9){
TblCrawlerArticleRelation tblCrawlerArticleRelation = new TblCrawlerArticleRelation();
tblCrawlerArticleRelation.setRelateId(articleId);
tblCrawlerArticleRelation.setArticleType((byte) ArticleTypeEnum.TBLCRAWLER.getValue());
tblCrawlerArticleRelation.setCrawlerId(req.getCrawlerId());
tblCrawlerArticleRelation.setCreateTime(System.currentTimeMillis());
}
}
@Override
public TblCrawlerInfoQueryRsp queryTblCrawlerInfoById(Integer id) {
... ...
... ... @@ -390,7 +390,7 @@
width:200,
onClick: function () {
$("#publishArticleForm").form("submit",{
url : serverContextPath+"/grassArticle/publishArticle",
url : serverContextPath+"/tblCrawlerArticle/publishCrawlerArticle",
onSubmit : function(param) {
debugger;
if (!$("#publishArticleForm").form("validate")) {
... ... @@ -489,7 +489,7 @@
width:200,
onClick: function () {
$("#publishArticleForm").form("submit",{
url : serverContextPath+"/grassArticle/saveArticleDraft",
url : serverContextPath+"/tblCrawlerArticle/saveTblArticleDraft",
onSubmit : function(param) {
debugger;
if (!$("#publishArticleForm").form("validate")) {
... ... @@ -720,7 +720,7 @@
return;
}
$("#publishArticleForm").form("submit",{
url : serverContextPath+"/grassArticle/timerPublish",
url : serverContextPath+"/tblCrawlerArticle/tblTimerPublish",
onSubmit : function(param) {
debugger;
if (!$("#publishArticleForm").form("validate")) {
... ...