Authored by 张帅

修复bug

... ... @@ -8,11 +8,16 @@ 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.IGrassArticleService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GrassArticleReq;
... ... @@ -22,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
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.Component;
import javax.annotation.Resource;
... ... @@ -49,12 +55,18 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
@Resource
private IGrassLabelDAO grassLabelDAO;
@Resource
private IAuthorDAO authorDAO;
@Autowired
private ServiceCaller serviceCaller;
private final static String BLOCK_TEXT = "text";
private final static String BLOCK_IMAGE = "image";
@Value("${uic.service.url:http://uic.yohoops.org/uic}")
private String uicUrl;
@Override
public void publishArticle(GrassArticleReq req) throws PlatformException {
logger.info("enter publishArticle, req is {}", req);
... ... @@ -224,15 +236,17 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
Integer articleId = req.getArticleId();
Integer source = req.getSource()==null || req.getSource() == 0 ? null:req.getSource();
Integer authStatus = req.getAuthStatus()==null ||req.getAuthStatus()==8 ? null:req.getAuthStatus();
Integer authorUid =null;
Integer isRecommend = req.getIsRecommend()==null ||req.getIsRecommend()==8 ? null:req.getIsRecommend();
Integer isTop = req.getIsTop()==null ||req.getIsTop()==8 ? null:req.getIsTop();
List<Integer> authorUids =null;
String authName = req.getPublisher();
String startTime = req.getStartTimeStr();
String endTime = req.getEndTimeStr();
Long startTimeInt = null;
Long endTimeInt = null;
if(StringUtils.isNumeric(authName)){
authorUid = Integer.valueOf(authName);
};
if(StringUtils.isNotEmpty(authName)){
authorUids = getUidByNickName(authName);
}
if(StringUtils.isNotEmpty(startTime)){
startTimeInt = Long.valueOf(startTime);
}
... ... @@ -241,10 +255,10 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
}
int page = req.getPage();
int size = req.getSize();
int total = grassArticleDao.selectArticleCount(articleId, source, authStatus,authorUid,startTimeInt, endTimeInt);
int total = grassArticleDao.selectArticleCount(articleId, source, authStatus,authorUids,isRecommend, isTop,startTimeInt, endTimeInt);
logger.info("getArticleList: grassArticleDao.getArticleCount: articleId is {}, source is {}, total is {}", articleId, source, total);
int offset = (page - 1) * size;
List<GrassArticle> articleList = grassArticleDao.selectArticleList(articleId, source, authStatus,authorUid,startTimeInt, endTimeInt,offset, size);
List<GrassArticle> articleList = grassArticleDao.selectArticleList(articleId, source, authStatus,authorUids,isRecommend, isTop,startTimeInt, endTimeInt,offset, size);
PageResponseVO rsp = new PageResponseVO();
rsp.setList(buildArticleDetail(articleList));
rsp.setTotal(total);
... ... @@ -253,6 +267,25 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
return rsp;
}
private List<Integer> getUidByNickName(String nickName){
String url = uicUrl + "/UserInfoRest/getUserInfoByNickName";
BaseReqBO<String> uicReq = new BaseReqBO<>();
uicReq.setParam(nickName);
logger.info("getUidByNickName nickName={}, url={}", uicReq.getParam(), url);
try{
UserInfoRspBO[] userInfoRspBOS = serviceCaller.post("uic.getUserInfoByNickName", url, uicReq, UserInfoRspBO[].class, null).get();
if(userInfoRspBOS == null || userInfoRspBOS.length == 0){
return null;
}
//用户的基本信息
List<UserInfoRspBO> userInfoRspBOList = Arrays.asList(userInfoRspBOS);
List<Integer> uids = userInfoRspBOList.stream().map(userInfoRspBO -> userInfoRspBO.getYohoUid()).distinct().collect(Collectors.toList());
return uids;
}catch (Exception e){
return null;
}
}
@Override
@Database(ForceMaster = true)
public void updateArticle(GrassArticleReq req) throws PlatformException {
... ... @@ -406,14 +439,26 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
skns.add(product.getProductSkn());
sknMap.put(product.getArticleId(), skns);
});
List<Integer> uids = articleList.stream().filter(article -> article.getAuthorType()==1).map(GrassArticle::getAuthorUid).distinct().collect(Collectors.toList());
List<Integer> authoruids = articleList.stream().filter(article -> article.getAuthorType()==2).map(GrassArticle::getAuthorUid).distinct().collect(Collectors.toList());
//用户的基本信息(昵称 头像等)
Map<Integer,UserInfoRspBO> userInfoMap = getUsersInfo(uids);
Map<Integer,Author> authorInfoMap = getAuthorInfo(authoruids);
List<ArticleDetailRspBo> rspBoList = Lists.newArrayList();
articleList.forEach(article -> {
ArticleDetailRspBo rspBo = new ArticleDetailRspBo();
rspBo.setArticleId(article.getId());
rspBo.setArticleContent(textMap.get(article.getId()));
rspBo.setArticleContent(textMap.get(article.getId()) == null ? "" : textMap.get(article.getId()));
rspBo.setAuthorUid(article.getAuthorUid());
// rspBo.setTopicName(getArticleName(article.getTopicId()));
rspBo.setNickName("");
if(article.getAuthorType() ==2){
Author author = authorInfoMap.get(article.getAuthorUid());
rspBo.setNickName(author == null ? "" : author.getUsername());
}else {
UserInfoRspBO userinfo = userInfoMap.get(article.getAuthorUid());
rspBo.setNickName(userinfo == null ? "" : userinfo.getNickName());
}
rspBo.setCommentCount(article.getCommentCount());
rspBo.setShareCount(article.getShareCount());
rspBo.setFavorCount(article.getFavoriteCount());
... ... @@ -430,6 +475,42 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
return rspBoList;
}
//调uic 获取用户的基本信息
private Map<Integer,UserInfoRspBO> getUsersInfo(List<Integer> uidList) {
Map<Integer,UserInfoRspBO> resultMap = new HashMap<>();
String url = uicUrl + "/UserInfoRest/getUserInfoListByYohoUid";
UicUserReqBO req = new UicUserReqBO();
StringBuilder sb = new StringBuilder();
for(Integer u : uidList){
sb.append(u).append(",");
}
String uids = org.apache.commons.lang.StringUtils.removeEnd(sb.toString(), ",");
req.setUids(uids);
try{
logger.info("getUsersInfo uids={}, url={}", uids, url);
UserInfoRspBO[] userBaseInfo = serviceCaller.post("uic.getUserInfoListByYohoUid", url, req, UserInfoRspBO[].class, null).get();
for(UserInfoRspBO bo : userBaseInfo){
resultMap.put(bo.getUid(), bo);
}
return resultMap;
}catch (Exception e){
return resultMap;
}
}
private Map<Integer,Author> getAuthorInfo(List<Integer> uidList) {
Map<Integer,Author> resultMap = new HashMap<>();
if(CollectionUtils.isEmpty(uidList)){
return resultMap;
}
List<Author> authors = authorDAO.selectByUids(uidList);
authors.forEach(author -> {
resultMap.put(author.getUid(), author);
});
return resultMap;
}
private Map<Integer, List<JSONObject>> buildLabelInfoMap(List<GrassArticleLabel> articleLabelList){
Map<Integer, List<JSONObject>> labelRspMap = Maps.newHashMap();
if(CollectionUtils.isEmpty(articleLabelList)){
... ...
... ... @@ -19,16 +19,17 @@
</div>
</form>
<table id="labelGroupListTable"></table>
</div>
<div region="center" id="labelGroupList" style="margin-left: 20px">
</div>
<script>
searchType=1;
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
checkedItemsObj ={};
searchType=1;
$("#labelGroupListTable").datagrid("load", {
query: $("#skn").textbox("getValue"),
status: 1,
... ... @@ -40,7 +41,8 @@
$("#searchUfoBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
checkedItemsObj ={};
searchType=2;
$("#labelGroupListTable").datagrid("load", {
query: $("#skn").textbox("getValue"),
// sales: "Y",
... ... @@ -129,19 +131,33 @@
title: "现价",
field: "sales_price",
width: 25,
align: "left",
align: "left"
}, {
title: "吊牌价",
field: "market_price",
width: 25,
align: "left",
align: "left" ,
formatter: function (value, rowData, rowIndex) {
var result=rowData.market_price;
if(rowData.market_price==null || rowData.market_price==''){
result ="——————————"
}
return result;
}
}, {
title: "库存",
field: "stock_number",
width: 25,
align: "left"
align: "left" ,
formatter: function (value, rowData, rowIndex) {
var result=rowData.stock_number;
if(rowData.stock_number==null || rowData.stock_number==''){
result ="——————————"
}
return result;
}
}
... ...
... ... @@ -54,13 +54,12 @@
<label>选择标签</label> <br>
<input id="labelId" name="labelId" class="easyui-combobox" style="width:60% "/>
<input id="labelIds" name="labelIds" hidden="hidden"/>
</td>
</tr>
<tr style="height: 20px">
<td >
<span style="color:red">*</span><label>选择图片</label>
<a id="addImage" class="btn btn-primary" >选择图片+</a>
<span style="color:red">*</span><label>选择图片</label><br>
<!--<a id="addImage" class="btn btn-primary" >选择图片+</a>-->
<input id="imgs" name="articleImages" hidden="hidden"/>
</td>
</tr>
... ... @@ -73,7 +72,7 @@
<tr style="height: 60px">
<td>
<label>关联商品</label> <br>
<a id="addSkn" class="btn btn-primary" onclick="getEditDialog()" style="font-size: 15px">选择商品+</a>
<a id="addSkn" class="btn btn-primary" style="font-size: 15px">选择商品+</a>
<input id="skns" name="articleSkns" hidden="hidden"/>
</td>
... ... @@ -87,7 +86,7 @@
</tr>
<tr>
<td valign="bottom">
<input id="subBotton" class="btn btn-primary" type="button" style="font-size: 20px; margin-top: 0px;margin-bottom: 0px;" value="保存"/>
<input id="subBotton" class="btn btn-primary" style="font-size: 20px; margin-top: 0px;margin-bottom: 0px;" value="保存"/>
</td>
</tr>
</table>
... ... @@ -105,8 +104,24 @@
var count = 1;
var checkedItems = [];
var checkedItemsObj = {};
var searchType = 1;
var checkType = 1;
$(function () {
$("#addImage").linkbutton({
iconCls : "icon-search",
onClick : function() {
}
});
$("#addSkn").linkbutton({
iconCls : "icon-search",
onClick : function() {
getEditDialog();
}
});
$("#articleUid").combobox({
required: true,
missingMessage: "发布用户不能为空",
... ... @@ -144,6 +159,7 @@
$("#subBotton").linkbutton({
iconCls: "icon-save",
width:100,
onClick: function () {
$("#publishArticleForm").form("submit",{
url : serverContextPath+"/grassArticle/publishArticle",
... ... @@ -184,7 +200,7 @@
if (data) {
data = $.parseJSON(data);
if (data.code == 200) {
// $.messager.show({ title : "提示", msg : "成功!" });
// $.messager.alert("保存成功","保存成功", "success");
alert("保存成功");
window.location.reload();
... ... @@ -223,6 +239,7 @@
iconCls : "icon-save",
handler:function(){
debugger;
$("#goodstd").html("<div id=\"good0\" style=\"float: left;margin-left: 30px;width: 300px\">\n" +
" </div>");
var skns = '';
... ... @@ -345,6 +362,10 @@
return -1;
}
function addcheckItem() {
if(searchType != checkType && checkedItems.length>0){
checkedItems=[];
}
checkType = searchType;
var i=0;
$("input[type='checkbox'][name='product_skn']:checked").each(function () {
if(i > 4){
... ...
... ... @@ -33,6 +33,10 @@
<input class="easyui-combobox" id="authStatus">
</input>
<input class="easyui-combobox" id="isRecommend">
</input>
<input class="easyui-combobox" id="isTop">
</input>
<input class="easyui-textbox" id="publisher">
</input>
<input class="easyui-textbox" id="articleId">
... ... @@ -66,15 +70,13 @@
iconCls : "icon-search",
onClick : function() {
//清空筛选数据
$("#authStatus").textbox('setValue',"");
$("#publishUid").textbox('setValue','');
$("#articleId").combobox('setValue','');
$("#source").combobox('setValue','');
debugger
$("#authStatus").combobox("setValue","");
$("#publishUid").textbox("setValue","");
$("#articleId").textbox("setValue","");
$("#source").combobox("setValue","");
$("#activityListTable").datagrid("load", {
authStatus: $("#authStatus").combobox("getValue"),
publisher: $("#publisher").textbox("getValue"),
articleId: $("#articleId").textbox("getValue"),
source: $("#source").textbox("getValue")
});
}
});
... ... @@ -83,7 +85,7 @@
debugger
$("#publisher").textbox({
required:false,
prompt: "用户uid"
prompt: "用户昵称"
});
$("#articleId").textbox({
required:false,
... ... @@ -94,7 +96,21 @@
textField : "text",
required:false,
prompt: "请选择状态",
data:[{text:"全部",value:"8"},{text:"未审核",value:"0"},{text:"审核通过",value:"1"},{text:"审核未通过",value:"2"}]
data:[{text:"全部",value:"8"},{text:"待审核",value:"0"},{text:"已通过",value:"1"},{text:"未通过",value:"2"}]
});
$("#isRecommend").combobox({
valueField : "value",
textField : "text",
required:false,
prompt: "请选择推荐状态",
data:[{text:"全部",value:"8"},{text:"未推荐",value:"0"},{text:"已推荐",value:"1"}]
});
$("#isTop").combobox({
valueField : "value",
textField : "text",
required:false,
prompt: "请选择置顶状态",
data:[{text:"全部",value:"8"},{text:"未置顶",value:"0"},{text:"已置顶",value:"1"}]
});
$("#source").combobox({
valueField : "value",
... ... @@ -111,16 +127,18 @@
var startTime="";
var endTime="";
if ($("#startTimeStr").datetimebox('getValue')!='') {
startTime = parseInt(new Date($("#startTimeStr").datetimebox('getValue')).getTime() / 1000);
startTime = parseInt(new Date($("#startTimeStr").datetimebox('getValue')).getTime() );
}
if ($("#endTimeStr").datetimebox('getValue')!='') {
endTime = parseInt(new Date($("#endTimeStr").datetimebox('getValue')).getTime() / 1000);
endTime = parseInt(new Date($("#endTimeStr").datetimebox('getValue')).getTime() );
}
$("#activityListTable").datagrid("load", {
authStatus: $("#authStatus").combobox("getValue"),
publisher: $("#publisher").textbox("getValue"),
articleId: $("#articleId").textbox("getValue"),
source: $("#source").combobox("getValue"),
isRecommend: $("#isRecommend").combobox("getValue"),
isTop: $("#isTop").combobox("getValue"),
startTimeStr:startTime,
endTimeStr:endTime
});
... ... @@ -184,10 +202,15 @@
},
{
title: "用户名",
field: "authorUid",
field: "nickName",
width: 25,
align: "left"
align: "left",
formatter: function (value, rowData, rowIndex) {
debugger
var uid ="uid:"+ rowData.authorUid;
var nickName ="昵称:"+ rowData.nickName;
return uid+"<br>"+nickName;
}
},
{
title: "被回复",
... ...