| | |
| | | } |
| | | article.setUpdateTime(new Date()); |
| | | boolean saveOrUpdate = articleService.saveOrUpdate(article); |
| | | if (saveOrUpdate){ |
| | | EsParam esParam = new EsParam(); |
| | | esParam.setIndexName("test"); |
| | | esParam.setTableName("jczz_article"); |
| | | if (flag) { |
| | | // 更新到es库 |
| | | elasticsearchDocumentService.addArticle(esParam, article); |
| | | }else { |
| | | esParam.setTableId(article.getId().toString()); |
| | | // 更新 |
| | | elasticsearchDocumentService.update(esParam,article); |
| | | } |
| | | } |
| | | return R.status(saveOrUpdate); |
| | | } |
| | | |
| | |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | List<Long> longs = Func.toLongList(ids); |
| | | boolean removeByIds = articleService.removeByIds(longs); |
| | | if (removeByIds){ |
| | | for (Long id : longs) { |
| | | EsParam esParam = new EsParam(); |
| | | esParam.setIndexName("test"); |
| | | esParam.setTableName("jczz_article"); |
| | | esParam.setTableId(id.toString()); |
| | | elasticsearchDocumentService.removeByQuery(esParam); |
| | | } |
| | | } |
| | | return R.status(removeByIds); |
| | | } |
| | | |