| | |
| | | package org.springblade.es.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.secure.annotation.PreAuth; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.es.service.ElasticsearchDocumentService; |
| | | import org.springblade.es.service.ElasticsearchIndexService; |
| | | import org.springblade.es.vo.EsParam; |
| | | import org.springblade.modules.answerRecord.entity.AnswerRecordEntity; |
| | | import org.springblade.modules.answerRecord.vo.AnswerRecordVO; |
| | | import org.springblade.modules.answerRecord.wrapper.AnswerRecordWrapper; |
| | | import org.springblade.modules.subjectChoices.vo.SubjectChoicesVO; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * es 全文检索 |
| | |
| | | * 初始化 |
| | | */ |
| | | @GetMapping("/init") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | @ApiOperationSupport(order = 2) |
| | | public R init(EsParam esParam) { |
| | | return R.status(elasticsearchDocumentService.init(esParam)); |
| | | } |
| | | |
| | | /** |
| | | * 新增数据 |
| | | */ |
| | | @GetMapping("/add") |
| | | @ApiOperationSupport(order = 3) |
| | | public R add(EsParam esParam) { |
| | | return R.status(elasticsearchDocumentService.add(esParam,null)); |
| | | } |
| | | |
| | | /** |
| | | * 修改数据 |
| | | */ |
| | | @GetMapping("/update") |
| | | @ApiOperationSupport(order = 4) |
| | | public R update(EsParam esParam) { |
| | | elasticsearchDocumentService.update(esParam,null); |
| | | return R.status(true); |
| | | } |
| | | // /** |
| | | // * 新增数据 |
| | | // */ |
| | | // @GetMapping("/add") |
| | | // @ApiOperationSupport(order = 3) |
| | | // public R add(EsParam esParam) { |
| | | // return R.status(elasticsearchDocumentService.add(esParam,null)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * 修改数据 |
| | | // */ |
| | | // @GetMapping("/update") |
| | | // @ApiOperationSupport(order = 4) |
| | | // public R update(EsParam esParam) { |
| | | // elasticsearchDocumentService.update(esParam,null,null); |
| | | // return R.status(true); |
| | | // } |
| | | |
| | | /** |
| | | * 根据索引删除 |
| | | */ |
| | | @PostMapping("/removeBatchByIndexNames") |
| | | @ApiOperationSupport(order = 5) |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | public R removeBatchByIndexNames(@RequestParam String indexNames) { |
| | | return R.status(elasticsearchDocumentService.removeBatchByIndexNames(Func.toStrList(indexNames))); |
| | | } |
| | |
| | | * 根据条件删除 |
| | | */ |
| | | @PostMapping("/removeByQuery") |
| | | @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) |
| | | @ApiOperationSupport(order = 6) |
| | | public R removeByQuery(EsParam esParam) { |
| | | return R.status(elasticsearchDocumentService.removeByQuery(esParam)); |