| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import static org.springblade.common.cache.CacheNames.ARTICLE_KEY; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改资讯信息", notes = "传入article") |
| | | public R submit(@RequestBody Article article) { |
| | | CacheUtil.clear(ARTICLE_KEY); |
| | | boolean flag = false; |
| | | if (null == article.getId()) { |
| | | flag = true; |
| | |
| | | } |
| | | 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); |
| | | } |
| | | |
| | |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | return R.status(articleService.removeByIds(Func.toLongList(ids))); |
| | | List<Long> longs = Func.toLongList(ids); |
| | | boolean removeByIds = articleService.removeByIds(longs); |
| | | return R.status(removeByIds); |
| | | } |
| | | |
| | | /** |