批量删除文章

master
ck 5 years ago
parent afcb50d3bf
commit 772e38dbc4

@ -77,4 +77,15 @@ public class ArticleController {
ajaxResult.setData(pageJson);
return ajaxResult;
}
/**
*
* @param jsonObject
* @return
*/
@RequestMapping("/del-article-list")
public AjaxResult delArticleList(@RequestBody JSONObject jsonObject) {
AjaxResult ajaxResult = articleSerive.delArticleList(jsonObject);
return ajaxResult;
}
}

@ -36,4 +36,12 @@ public interface ArticleSerive {
* @return
*/
JSONObject searchArticleListByPage(JSONObject jsonObject);
/**
*
* @param jsonObject
* @return
*/
AjaxResult delArticleList(JSONObject jsonObject);
}

@ -1,5 +1,6 @@
package com.jingcheng.cms.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jingcheng.cms.constants.Constants;
import com.jingcheng.cms.mapper.ArticleMapper;
@ -143,5 +144,25 @@ public class ArticleSerivceImpl implements ArticleSerive {
return pageJson;
}
@Override
public AjaxResult delArticleList(JSONObject jsonObject) {
AjaxResult ajaxResult = new AjaxResult();
JSONArray jsonArray = jsonObject.getJSONArray("ids");
if (null == jsonArray || jsonArray.size() == 0 ){
ajaxResult.setRetmsg("id列表不可为空");
return ajaxResult;
}
List<Long> idList = JSONObject.parseArray(jsonArray.toJSONString(), Long.class);
for (Long id : idList){
Article article = articleMapper.selectByPrimaryKey(id);
if (null == article){
continue;
}
article.setState(Constants.DISABLE);
articleMapper.updateByPrimaryKeySelective(article);
}
return null;
}
}

Loading…
Cancel
Save