package com.bawei.es.controller;

import com.bawei.common.core.domain.R;
import com.bawei.common.core.web.domain.AjaxResult;
import com.bawei.es.service.EsDocService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/doc")
public class EsDocController {
    @Autowired
    private EsDocService esDocService;

    @GetMapping("/queryList/{indexName}")
    public R queryList(@PathVariable String indexName, @RequestBody Map<String,Object> docMsg){
        return R.ok(esDocService.queryList(indexName,docMsg),"数据查询成功");
    }

    @PutMapping("/batchAddDoc/{indexName}")
    public R batchAddDoc(@PathVariable String indexName, @RequestBody Map<String,Object> docMsg){
        esDocService.batchAddDoc(indexName,docMsg);
        return R.ok(null,"批量操作文档数据成功");
    }

    @DeleteMapping("/bathDeleteDoc/{indexName}")
    public R bathDeleteDoc(@PathVariable String indexName, @RequestBody List<String> ids){
        esDocService.bathDeleteDoc(indexName,ids);
        return R.ok(null,"批量删除文档数据成功");
    }
}
