Authored by 张帅

Merge branch 'test6.8.7' into dev-grass-0305

# Conflicts:
#	grass/src/main/java/com/yohobuy/platform/grass/restapi/GrassArticleController.java
#	grass/src/main/java/com/yohobuy/platform/grass/service/IGrassArticleService.java
package com.yohobuy.platform.grass.restapi;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yohobuy.platform.common.exception.PlatformException;
import com.yohobuy.platform.grass.service.IGrassArticleService;
import com.yohobuy.platform.model.common.ApiResponse;
... ... @@ -92,4 +91,15 @@ public class GrassArticleController {
}
return new ApiResponse.ApiResponseBuilder().build();
}
@RequestMapping("/deleteArticle")
public ApiResponse deleteArticle(@RequestBody GrassArticleReq req){
logger.info("deleteArticle begin, req is {}",req);
try {
grassArticleService.deleteArticle(req);
} catch (PlatformException e) {
return new ApiResponse.ApiResponseBuilder().code(e.getCode()).message(e.getMessage()).build();
}
return new ApiResponse.ApiResponseBuilder().build();
}
}
... ...
... ... @@ -26,4 +26,6 @@ public interface IGrassArticleService {
void updateArticleDraft(GrassArticleReq req) throws PlatformException;
void deleteArticle(GrassArticleReq req) throws PlatformException;
}
... ...
package com.yohobuy.platform.grass.service;
import com.yohobuy.platform.model.grass.request.GrassCacheReq;
/**
* Created by shengguo.cai on 2019/3/4.
*/
public interface IGrassRefreshCacheService {
public void refreshGrassCache(GrassCacheReq reqVO);
}
... ...
... ... @@ -5,7 +5,6 @@ import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.service.model.social.request.BaseReqBO;
import com.yoho.service.model.social.request.UicUserReqBO;
import com.yoho.service.model.social.response.UserInfoRspBO;
import com.yohobuy.platform.common.helper.UserHelper;
import com.yohobuy.platform.dal.common.BeanConvertUtil;
import com.yohobuy.platform.dal.grass.IGrassArticleCommentDao;
import com.yohobuy.platform.dal.grass.model.GrassArticleCommentQueryDo;
... ... @@ -128,7 +127,6 @@ public class GrassArticleCommentServiceImpl implements IGrassArticleCommentServi
@Override
public void modifyStatus(ArticleCommentModifyStatusReq req) {
Integer reviewerId = new UserHelper().getUserId();
grassArticleCommentDao.updateStatus(req.getIds(),req.getStatus(),reviewerId, DateUtil.currentTimeSeconds());
grassArticleCommentDao.updateStatus(req.getIds(),req.getStatus(),req.getReviewer(), DateUtil.currentTimeSeconds());
}
}
... ...
... ... @@ -7,21 +7,20 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.ServiceError;
import com.yoho.service.model.social.request.BaseReqBO;
import com.yoho.service.model.social.request.UicUserReqBO;
import com.yoho.service.model.social.response.UserInfoRspBO;
import com.yohobuy.platform.common.exception.PlatformException;
import com.yohobuy.platform.common.helper.ImagesHelper;
import com.yohobuy.platform.common.util.DateUtil;
import com.yohobuy.platform.dal.grass.*;
import com.yohobuy.platform.dal.grass.model.*;
import com.yohobuy.platform.dal.guang.IAuthorDAO;
import com.yohobuy.platform.dal.guang.model.Author;
import com.yohobuy.platform.grass.service.IGrassArticleCommentService;
import com.yohobuy.platform.grass.service.IGrassArticleService;
import com.yohobuy.platform.grass.service.IGrassRefreshCacheService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GrassArticleReq;
import com.yohobuy.platform.model.grass.request.GrassCacheReq;
import com.yohobuy.platform.model.grass.response.ArticleDetailRspBo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringEscapeUtils;
... ... @@ -54,7 +53,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
@Resource
private IGrassArticleCommentDao grassArticleCommentDao;
@Resource
private IGrassArticlePraiseDao grassArticlePraiseDao;
@Resource
private IGrassArticleLabelDao grassArticleLabelDao;
@Resource
... ... @@ -65,6 +65,12 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
@Autowired
private ServiceCaller serviceCaller;
@Autowired
private IGrassArticleDeleteLogDao grassArticleDeleteLogDao;
@Autowired
private IUserFavoriteArticleDao userFavoriteArticleDao;
@Autowired
private IGrassRefreshCacheService grassRefreshCacheService;
private final static String BLOCK_TEXT = "text";
private final static String BLOCK_IMAGE = "image";
... ... @@ -648,6 +654,30 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
}
@Override
public void deleteArticle(GrassArticleReq req) throws PlatformException {
int articleId = req.getArticleId();
int flag = grassArticleDao.deleteById(articleId);
logger.info("after deleteArticle,flag is {},articleId is {}",flag,articleId);
if(flag == 0){
return;
}
grassArticleBlockDao.deleteByArticleId(articleId);
grassArticleCommentDao.deleteByDestIdAndColumnType(articleId,GrassArticleComment.ColumnType.ARTICLE.getValue());
grassArticlePraiseDao.deleteByArticleId(articleId);
userFavoriteArticleDao.deleteByArticleId(articleId);
grassArticleLabelDao.deleteByArticleId(articleId);
grassArticleProductDao.deleteByArticleId(articleId);
GrassArticleDeleteLog grassArticleDeleteLog = new GrassArticleDeleteLog(articleId,req.getAuthorizeAccount(), DateUtil.getCurrentTimeSeconds());
grassArticleDeleteLogDao.insertByGrassArticleDeleteLog(grassArticleDeleteLog);
//TODO 清空缓存,cdn啥的
GrassCacheReq cacheReq = new GrassCacheReq();
cacheReq.setClearCode(GrassCacheReq.CLEARCODE_ARTICLE);
cacheReq.setElementId(String.valueOf(articleId));
grassRefreshCacheService.refreshGrassCache(cacheReq);
}
private List<ArticleDetailRspBo> buildArticleDetail( List<GrassArticle> articleList){
if(CollectionUtils.isEmpty(articleList)){
return new ArrayList<>();
... ...
package com.yohobuy.platform.grass.service.impl;
import com.yoho.core.rest.client.ServiceCaller;
import com.yohobuy.platform.grass.service.IGrassRefreshCacheService;
import com.yohobuy.platform.model.grass.request.GrassCacheReq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by shengguo.cai on 2019/3/4.
*/
@Service
public class GrassRefreshCacheServiceImpl implements IGrassRefreshCacheService{
private Logger logger = LoggerFactory.getLogger(GrassRefreshCacheServiceImpl.class);
@Value("${api.yoho.url:http://api.yoho.cn}")
private String apiUrl;
@Autowired
private ServiceCaller serviceCaller;
@Override
public void refreshGrassCache(GrassCacheReq reqVO){
logger.info("refreshGrassCache: param is {}", reqVO);
if(reqVO == null || reqVO.getClearCode() == 0){
return;
}
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
public void run() {
String elementId = reqVO.getElementId();
int clearCode = reqVO.getClearCode();
try{
String url = apiUrl + "?method=clear.grass.cache&elementId=" + elementId + "&clearCode=" + clearCode;
logger.info("start refreshGrassCache, url is: {}, elementId is {}, clearCode is {}", url, elementId, clearCode);
serviceCaller.get("app.clearGrassCache", url, null, String.class, null);
logger.info("success refreshGrassCache elementId is {}, clearCode is {}", elementId, clearCode);
}catch (Exception e){
logger.info("fail refreshGrassCache, elementId is {}, clearCode is {}, error is {}", elementId, clearCode, e);
}
}
});
}
}
... ...
... ... @@ -47,7 +47,7 @@
<dependency>
<groupId>com.yohobuy.platform</groupId>
<artifactId>platform-dal</artifactId>
<version>1.0.3-6.8.6-SNAPSHOT</version>
<version>1.0.3-6.8.7-SNAPSHOT</version>
</dependency>
</dependencies>
... ...
... ... @@ -26,6 +26,7 @@ public final class ActivtyTemplatedConvert {
return null;
}
ActivtyTemplated bo = new ActivtyTemplated();
bo.setId(req.getId());
bo.setTitle(req.getTitle());
bo.setStatus(req.getStatus());
bo.setIsDel(req.getIsDel());
... ...
... ... @@ -224,6 +224,7 @@ public class ActivtyTemplatedController extends BasicController{
@RequestMapping(value = "/getActivtyTemplatedList")
@ResponseBody
public ApiResponse getActivtyTemplatedList(@RequestBody ActivityTemplatedPageBo req){
logger.info("ActivtyTemplatedController :: getActivtyTemplatedList req is {}",req);
PageResponseVO<ActivtyTemplatedBo> pageResp = activtyTemplatedService.getListByPage(req);
return new ApiResponse.ApiResponseBuilder()
.code(SUCCESS)
... ...
... ... @@ -24,7 +24,7 @@
<dependency>
<groupId>com.yoho.service.platform.model</groupId>
<artifactId>platform-service-model</artifactId>
<version>1.2.3-6.8.6-SNAPSHOT</version>
<version>1.2.3-6.8.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
... ... @@ -59,7 +59,7 @@
<dependency>
<groupId>com.yohobuy.platform</groupId>
<artifactId>platform-common</artifactId>
<version>1.0.3-6.8.6-SNAPSHOT</version>
<version>1.0.3-6.8.7-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
... ...
... ... @@ -350,9 +350,9 @@ datasources:
- com.yohobuy.platform.dal.grass.IGrassArticleCommentDao
- com.yohobuy.platform.dal.grass.IGrassUserAchieveDAO
- com.yohobuy.platform.dal.grass.IGrassArticleLabelDao
- com.yohobuy.platform.dal.grass.IGrassArticlePraiseDao
- com.yohobuy.platform.dal.grass.IUserFavoriteArticleDao
- com.yohobuy.platform.dal.grass.IGrassArticleDeleteLogDao
yhb_promotion:
servers:
... ...
... ... @@ -348,6 +348,9 @@ datasources:
- com.yohobuy.platform.dal.grass.IGrassArticleCommentDao
- com.yohobuy.platform.dal.grass.IGrassUserAchieveDAO
- com.yohobuy.platform.dal.grass.IGrassArticleLabelDao
- com.yohobuy.platform.dal.grass.IGrassArticlePraiseDao
- com.yohobuy.platform.dal.grass.IUserFavoriteArticleDao
- com.yohobuy.platform.dal.grass.IGrassArticleDeleteLogDao
yhb_promotion:
servers:
- ${jdbc.mysql.yhbpromotion.master}
... ...
... ... @@ -273,6 +273,7 @@
str += "<a role='switchR' class='btn-success' dataId='"+rowData.articleId+ "' index='"+ rowIndex + "' status='1' style='margin-left:10px'>审核通过</a>";
}
//还有一个编辑按钮
str += "<a role='deleteR' class='btn-success' dataId='"+rowData.articleId+ "' index='"+ rowIndex + "' style='margin-left:10px'>删除</a>";
return str;
}
}
... ... @@ -316,6 +317,24 @@
}
});
$(this).datagrid("getPanel").find("a[role='deleteR']").linkbutton({
iconCls : "icon-edit",
onClick: function () {
var dataId = $(this).attr("dataId");
$.messager.confirm("确认", "确认删除这篇文章吗?", function (flag) {
if(flag){
$.post(serverContextPath + "/grassArticle/deleteArticle?articleId=" + dataId, function (data) {
if(data.code != 200){
alert(data.message);
}else{
$("#activityListTable").datagrid("reload");
}
}, "json");
}
});
}
});
/* $(this).datagrid("getPanel").find("a[role='switchT']").linkbutton({
iconCls : "icon-edit",
onClick: function () {
... ...