Authored by 张帅

提交

... ... @@ -23,7 +23,7 @@ public class GrassArticleController {
IGrassArticleService grassArticleService;
@RequestMapping("/publishArticle")
public ApiResponse publishArticle( GrassArticleReq req){
public ApiResponse publishArticle(@RequestBody GrassArticleReq req){
logger.info("grassArticle publishArticle begin, req is {}", req);
try {
req.setAuthStatus(1);
... ... @@ -41,13 +41,13 @@ public class GrassArticleController {
}
@RequestMapping("/articleList")
public ApiResponse grassArticleList( GrassArticleReq req){
public ApiResponse grassArticleList(@RequestBody GrassArticleReq req){
logger.info("grassArticle grassArticleList begin, req is {}");
return new ApiResponse.ApiResponseBuilder().data(grassArticleService.getArticleList(req)).build();
}
@RequestMapping("/updateArticle")
public ApiResponse updateArticle( GrassArticleReq req){
public ApiResponse updateArticle(@RequestBody GrassArticleReq req){
logger.info("grassArticle grassArticleList begin, req is {}");
try {
grassArticleService.updateArticle(req);
... ... @@ -58,13 +58,13 @@ public class GrassArticleController {
}
@RequestMapping("/getUserInfo")
public ApiResponse getUserInfo( GrassUserManageReq req){
logger.info("grassArticle grassArticleList begin, req is {}");
public ApiResponse getUserInfo(@RequestBody GrassUserManageReq req){
logger.info("grassArticle getUserInfo begin, req is {}");
return new ApiResponse.ApiResponseBuilder().data(grassArticleService.getUserInfo(req.getUid())).build();
}
@RequestMapping("/saveArticleDraft")
public ApiResponse saveArticleDraft( GrassArticleReq req){
public ApiResponse saveArticleDraft(@RequestBody GrassArticleReq req){
logger.info("grassArticle saveArticleDraft begin, req is {}", req);
try {
req.setAuthStatus(9);
... ... @@ -76,8 +76,20 @@ public class GrassArticleController {
}
@RequestMapping("/draftArticleList")
public ApiResponse draftArticleList( GrassArticleReq req){
logger.info("grassArticle grassArticleList begin, req is {}");
public ApiResponse draftArticleList(@RequestBody GrassArticleReq req){
logger.info("grassArticle draftArticleList begin, req is {}");
return new ApiResponse.ApiResponseBuilder().data(grassArticleService.draftArticleList(req)).build();
}
@RequestMapping("/updateArticleDraft")
public ApiResponse updateArticleDraft(@RequestBody GrassArticleReq req){
logger.info("grassArticle updateArticleDraft begin, req is {}", req);
try {
grassArticleService.updateArticleDraft(req);
} catch (PlatformException e) {
return new ApiResponse.ApiResponseBuilder().code(e.getCode()).message(e.getMessage()).build();
}
return new ApiResponse.ApiResponseBuilder().build();
}
}
... ...
... ... @@ -24,4 +24,6 @@ public interface IGrassArticleService {
PageResponseVO<ArticleDetailRspBo> draftArticleList(GrassArticleReq req);
void updateArticleDraft(GrassArticleReq req) throws PlatformException;
}
... ...
... ... @@ -540,6 +540,114 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
return rsp;
}
@Override
public void updateArticleDraft(GrassArticleReq req) throws PlatformException {
// 操作类型,1 编辑后保存草稿箱 2 编辑后直接发布
Integer type = req.getDraftType();
//修改文章内容
Integer articleId = req.getArticleId();
if(articleId == null){
throw new PlatformException("articleId is null", 402);
}
List<Integer> labels = Lists.newArrayList();
String[] urls = req.getArticleImages().split(",");
String[] skns = null;
if(StringUtils.isNotEmpty(req.getArticleSkns())){
skns = req.getArticleSkns().split(",");
if(skns.length > 5){
logger.info("publishArticle , article products more than most publish number");
throw new PlatformException("publish products most number is 5 ", 405);
}
}
if(urls.length > 9){
logger.info("publishArticle , article images more than most publish number");
throw new PlatformException("publish images most number is 9 ", 405);
}
if(StringUtils.isNotEmpty(req.getLabelIds())){
labels = Arrays.stream(req.getLabelIds().split(",")).map(Integer::valueOf).collect(Collectors.toList());
if(labels.size() > 5){
logger.info("publishArticle , article labels more than most publish number");
throw new PlatformException("publish labels most number is 5 ", 405);
}
}
//修改文章主体内容
GrassArticle grassArticle = new GrassArticle();
grassArticle.setId(articleId);
grassArticle.setAuthorUid(req.getAuthorUid());
grassArticle.setAuthStatus(type==1? 9 :1);
grassArticle.setAuthTime(type==1?0L : System.currentTimeMillis());
grassArticle.setUpdateTime(System.currentTimeMillis());
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
//文章内容
grassArticleBlockDao.deleteByArticleId(articleId);
//图片内容
List<String> reqlist = req.getArticleImages() == null ? Lists.newArrayList() : Lists.newArrayList(req.getArticleImages().split(","));
//新增
List<GrassArticleBlock> addList = Lists.newArrayList();
int contentOrder = 0;
for (String src : reqlist) {
GrassArticleBlock content = new GrassArticleBlock();
content.setArticleId(articleId);
content.setContentData(getBlock(BLOCK_IMAGE,src));
content.setCreateTime(System.currentTimeMillis());
content.setTemplateKey("image");
content.setOrderBy(contentOrder);
contentOrder++;
addList.add(content);
}
//文字内容
if(StringUtils.isNotEmpty(req.getContent())){
GrassArticleBlock content = new GrassArticleBlock();
content.setArticleId(articleId);
content.setContentData(getBlock(BLOCK_TEXT,req.getContent()));
content.setCreateTime(System.currentTimeMillis());
content.setTemplateKey("text");
content.setOrderBy(contentOrder);
addList.add(content);
}
if(CollectionUtils.isNotEmpty(addList)){
grassArticleBlockDao.insertArticleContents(addList);
}
//商品
grassArticleProductDao.deleteByArticleId(articleId);
List<String> reqSknlist = StringUtils.isEmpty(req.getArticleSkns()) ? Lists.newArrayList() : Lists.newArrayList(req.getArticleSkns().split(","));
//新增
List<GrassArticleProduct> addSknList = Lists.newArrayList();
int orderBy = 0;
for (String skn : reqSknlist) {
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
grassArticleSkn.setArticleId(articleId);
grassArticleSkn.setProductSkn(Integer.valueOf(skn));
grassArticleSkn.setCreateTime(System.currentTimeMillis());
grassArticleSkn.setOrderBy(orderBy);
grassArticleSkn.setProductSource(req.getSknType());
orderBy++;
addSknList.add(grassArticleSkn);
}
if(CollectionUtils.isNotEmpty(addSknList)){
grassArticleProductDao.insertArticleSkns(addSknList);
}
//构建lables 数据
grassArticleLabelDao.deleteByArticleId(articleId);
List<GrassArticleLabel> grassArticleLabels = buildArticleLabels(articleId, labels,grassArticle.getAuthStatus());
try{
if(CollectionUtils.isNotEmpty(grassArticleLabels)){
grassArticleLabelDao.insertArticleLabels(grassArticleLabels);
}
}catch (Exception e){
logger.warn("publishArticle ,grassArticleLableDao insertArticleLables error, uid is {}, e is {}", req.getAuthorUid(), e);
}
}
private List<ArticleDetailRspBo> buildArticleDetail( List<GrassArticle> articleList){
if(CollectionUtils.isEmpty(articleList)){
return new ArrayList<>();
... ...
... ... @@ -42,7 +42,7 @@
<input id="endTimeStr" name="endTimeStr" class="easyui-datetimebox" data-options="prompt:'结束时间'"/>
</input>
<a id="searchBtn" class="btn-info">筛选</a>
<a id="searchBtn1" class="btn-info">筛选</a>
<!--<a id="addActivityBtn" class="btn-success">新增</a>-->
<a id="allBtn" class="btn-info">全部 </a>
... ... @@ -102,7 +102,7 @@
// 检索按钮
$("#searchBtn").linkbutton({
$("#searchBtn1").linkbutton({
iconCls : "icon-search",
onClick : function() {
debugger;
... ... @@ -134,7 +134,7 @@
publisher: $("#publisher").textbox("getValue"),
articleId: $("#articleId").textbox("getValue"),
},
url: contextPath + "/grassArticle/draftArticleList",
url: serverContextPath + "/grassArticle/draftArticleList",
method: 'POST',
loadFilter: function (data) {
var tmp = defaultLoadFilter(data);
... ... @@ -348,7 +348,7 @@
function publishArticle(id) {
debugger
var operateType = 5;
$.post(contextPath + "/grassArticle/updateArticle?articleId=" + id + "&operateType="+ operateType, function (data) {
$.post(serverContextPath + "/grassArticle/updateArticle?articleId=" + id + "&operateType="+ operateType, function (data) {
if(data.code != 200){
alert(data.message);
}else{
... ... @@ -360,7 +360,7 @@
function switchTimer(id, status,publishTime) {
debugger
var operateType = status == 1 ? 3 : 4;
$.post(contextPath + "/grassArticle/updateArticle?articleId=" + id + "&publishTime=" + publishTime+ "&operateType="+ operateType, function (data) {
$.post(serverContextPath + "/grassArticle/updateArticle?articleId=" + id + "&publishTime=" + publishTime+ "&operateType="+ operateType, function (data) {
if(data.code != 200){
alert(data.message);
}else{
... ...
... ... @@ -40,6 +40,8 @@
<div region="center" id="labelGroupList" style="margin-left: 20px">
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
<form name="publishArticleForm" id="publishArticleForm" method="post" >
<input id="draftType" name="draftType" hidden="hidden"/>
<input id="draftArticleId" name="articleId" hidden="hidden"/>
<div style="margin-top: 20px;margin-left: 30px">
<table border="0" style="width:100%;margin-top:5px;line-height:30px;" id="tab">
... ... @@ -102,7 +104,7 @@
</tr>
<tr style="height: 60px">
<td id="goodstd">
<div id="good0" style="float: left;margin-left: 30px;width: 150px;">
<div id="good0" style="float: left;margin-left: 30px;width: 300px;">
</div>
</td>
... ... @@ -154,7 +156,7 @@
//发送请求
$.ajax({
type: "POST",
url: contextPath + "/grassArticle/getUserInfo", //提交到后端的url
url: serverContextPath + "/grassArticle/getUserInfo", //提交到后端的url
dataType: 'json',
data:{
uid : $(this).textbox("getValue")
... ... @@ -198,7 +200,7 @@
valueField: 'id',
textField: 'labelName',
multiple:true,
url : contextPath + "/grassLabelManage/getAllGrassLabelInfo",
url : serverContextPath + "/grassLabelManage/getAllGrassLabelInfo",
loadFilter: function (data) {
return defaultLoadFilter(data);
},
... ... @@ -253,7 +255,6 @@
removeSingleItemById(product_skn);
var skns = '';
for (var i = 0; i < checkedItems.length; i++) {
buildgood(i,checkedItems[i]);
if( i == checkedItems.length -1){
skns = skns+ checkedItems[i]
}else{
... ... @@ -270,13 +271,14 @@
width:200,
onClick: function () {
$("#publishArticleForm").form("submit",{
url : contextPath+"/grassArticle/publishArticle",
url : serverContextPath+"/grassArticle/updateArticleDraft",
onSubmit : function(param) {
debugger;
if (!$("#publishArticleForm").form("validate")) {
return false;
}
$("#draftType").val(2);
var imgs = '';
var imageCount = 0;
$("input[name='url']").each(function(j,item){
... ... @@ -294,6 +296,10 @@
$.messager.alert("发布失败", "最多只能选择9张图片", "error");
return false;
}
if(imageCount < 1){
$.messager.alert("发布失败", "请选择至少一张图片", "error");
return false;
}
var labels = '';
$("input[name='labelId']").each(function(j,item){
debugger
... ... @@ -332,14 +338,14 @@
width:200,
onClick: function () {
$("#publishArticleForm").form("submit",{
url : contextPath+"/grassArticle/saveArticleDraft",
url : serverContextPath+"/grassArticle/updateArticleDraft",
onSubmit : function(param) {
debugger;
if (!$("#publishArticleForm").form("validate")) {
return false;
}
$("#draftType").val(1);
var imgs = '';
var imageCount = 0;
$("input[name='url']").each(function(j,item){
... ... @@ -357,6 +363,10 @@
$.messager.alert("保存失败", "最多只能选择9张图片", "error");
return false;
}
if(imageCount < 1){
$.messager.alert("发布失败", "请选择至少一张图片", "error");
return false;
}
var labels = '';
$("input[name='labelId']").each(function(j,item){
debugger
... ... @@ -395,7 +405,7 @@
height: 120,
realInputName: "url",
uploadInputName: "files",
url: contextPath + '/fileupload/uploads',
url: serverContextPath + '/fileupload/uploads',
queryParams: {
bucket: "grassImg"
},
... ... @@ -467,6 +477,7 @@
$("#articleUid").textbox("setValue", data.authorUid);
$("#draftArticleId").val(data.articleId);
//奖品数量不可修改
$("#content").val(data.articleContent);
... ... @@ -484,8 +495,10 @@
$("#imageUpload"+j).imageUpload("setValue",data.imgList[j-1])
}
debugger
if(data.sknList!=null && data.sknList.length>0){
initGoods(data.sknList,data.sknType);
$("#sknType").val(data.sknType);
}
}
});
... ... @@ -551,7 +564,7 @@
height: 120,
realInputName: "url",
uploadInputName: "files",
url: contextPath + '/fileupload/uploads',
url: serverContextPath + '/fileupload/uploads',
queryParams: {
bucket: "grassImg"
},
... ... @@ -641,7 +654,7 @@
}
function gooddiv(data) {
return " <span>商品图:<img width=\"120\" height=\"60\" src="+getImageUrl(data.default_images)+
return " <span>商品图:<img width=\"100\" height=\"60\" src="+getImageUrl(data.default_images)+
" /> <a href=\"#\" class=\"goodTag\" data-index=\""+data.product_skn+"\">x</a></span>" +
"<h5 style=\"margin-top: 0px;margin-bottom: 0px\">商品名:"+ data.product_name +"</h5>\n" +
"<h5 style=\"margin-top: 0px;margin-bottom: 0px\">价格:"+data.sales_price+"</h5>"
... ... @@ -734,16 +747,17 @@
function initGoods(skns,type) {
debugger
// var url=serverContextPath+"/grassArticle/queryGoods ";
var url = contextPath+"/search/queryGoods";
var url=serverContextPath+"/grassArticle/queryGoods ";
// var url = contextPath+"/search/queryGoods";
var query ='';
var params ='';
for (var i=0;i<skns;i++){
for (var i=0;i<skns.length;i++){
if(query==''){
query = skns[i];
}else{
query = query+","+skns[i];
}
checkedItems.push(skns[i]);
}
if(type==1){
params = "?query="+query+"&status=1&stocknumber=1&attribute_not=2";
... ... @@ -755,21 +769,20 @@
$.post(url+params, function (data) {
debugger
if(data.code == 200){
for (var i=0; i<data.list.length;i++){
var rowdata = data.list[i]
for (var i=0; i<data.data.list.length;i++){
var rowdata = data.data.list[i]
checkedItemsObj[rowdata.product_skn] = rowdata;
checkedItems.push(rowdata.product_skn);
}
var skns = '';
for (var i = 0; i < checkedItems.length; i++) {
buildgood(i,checkedItems[i]);
if( i == checkedItems.length -1){
skns = skns+ checkedItems[i]
var skns1 = '';
for (var j = 0; j < checkedItems.length; j++) {
buildgood(j,checkedItems[j]);
if( j == checkedItems.length -1){
skns1 = skns1+ checkedItems[j]
}else{
skns = skns+ checkedItems[i] +","
skns1 = skns1+ checkedItems[j] +","
}
}
$("#skns").val(skns);
$("#skns").val(skns1);
}
}, "json");
}
... ...
... ... @@ -195,7 +195,7 @@
//发送请求
$.ajax({
type: "POST",
url: contextPath + "/grassArticle/getUserInfo", //提交到后端的url
url: serverContextPath + "/grassArticle/getUserInfo", //提交到后端的url
dataType: 'json',
data:{
uid : $(this).textbox("getValue")
... ... @@ -239,7 +239,7 @@
valueField: 'id',
textField: 'labelName',
multiple:true,
url : contextPath + "/grassLabelManage/getAllGrassLabelInfo",
url : serverContextPath + "/grassLabelManage/getAllGrassLabelInfo",
loadFilter: function (data) {
return defaultLoadFilter(data);
},
... ... @@ -279,7 +279,6 @@
removeSingleItemById(product_skn);
var skns = '';
for (var i = 0; i < checkedItems.length; i++) {
buildgood(i,checkedItems[i]);
if( i == checkedItems.length -1){
skns = skns+ checkedItems[i]
}else{
... ... @@ -296,7 +295,7 @@
width:200,
onClick: function () {
$("#publishArticleForm").form("submit",{
url : contextPath+"/grassArticle/publishArticle",
url : serverContextPath+"/grassArticle/publishArticle",
onSubmit : function(param) {
debugger;
if (!$("#publishArticleForm").form("validate")) {
... ... @@ -320,6 +319,10 @@
$.messager.alert("发布失败", "最多只能选择9张图片", "error");
return false;
}
if(imageCount < 1){
$.messager.alert("发布失败", "请选择至少一张图片", "error");
return false;
}
var labels = '';
$("input[name='labelId']").each(function(j,item){
debugger
... ... @@ -358,7 +361,7 @@
width:200,
onClick: function () {
$("#publishArticleForm").form("submit",{
url : contextPath+"/grassArticle/saveArticleDraft",
url : serverContextPath+"/grassArticle/saveArticleDraft",
onSubmit : function(param) {
debugger;
if (!$("#publishArticleForm").form("validate")) {
... ... @@ -421,7 +424,7 @@
height: 120,
realInputName: "url",
uploadInputName: "files",
url: contextPath + '/fileupload/uploads',
url: serverContextPath + '/fileupload/uploads',
queryParams: {
bucket: "grassImg"
},
... ... @@ -564,7 +567,7 @@
height: 120,
realInputName: "url",
uploadInputName: "files",
url: contextPath + '/fileupload/uploads',
url: serverContextPath + '/fileupload/uploads',
queryParams: {
bucket: "grassImg"
},
... ...
... ... @@ -152,7 +152,7 @@
source: $("#source").textbox("getValue"),
authStatus: "1"
},
url: contextPath + "/grassArticle/articleList",
url: serverContextPath + "/grassArticle/articleList",
method: 'POST',
loadFilter: function (data) {
var tmp = defaultLoadFilter(data);
... ... @@ -401,7 +401,7 @@
function switchRecommend(id, status) {
debugger
var switchStatus = status == 1 ? 0 : 1;
$.post(contextPath + "/grassArticle/updateArticle?articleId=" + id + "&isRecommend=" + switchStatus+ "&operateType=0", function (data) {
$.post(serverContextPath + "/grassArticle/updateArticle?articleId=" + id + "&isRecommend=" + switchStatus+ "&operateType=0", function (data) {
if(data.code != 200){
alert(data.message);
}else{
... ... @@ -413,7 +413,7 @@
function switchTop(id, status) {
debugger
var switchStatus = status == 1 ? 0 : 1;
$.post(contextPath + "/grassArticle/updateArticle?articleId=" + id + "&isTop=" + switchStatus+ "&operateType=0", function (data) {
$.post(serverContextPath + "/grassArticle/updateArticle?articleId=" + id + "&isTop=" + switchStatus+ "&operateType=0", function (data) {
if(data.code != 200){
alert(data.message);
}else{
... ...