package com.nbclass.szxgl.controller.mobile;

import com.nbclass.system.controller.BaseController;
import com.nbclass.szxgl.mapper2.DataDictItemMapper;
import com.nbclass.szxgl.service.ElasticSearchService;
import com.nbclass.util.ResultUtil;
import com.nbclass.vo.base.ResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
@RequestMapping("/api")
public class ElasticSearchController extends BaseController {

    @Autowired
    private ElasticSearchService elasticSearchService;

    @Autowired
    private DataDictItemMapper dataDictItemMapper;

    /**
     * 全文检索
     * @param tagIds 标签
     * @param caseName 项目名称
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/getCaseName")
    public ResponseVo getCaseName(String tagIds,String caseName,Integer pageNum, Integer pageSize){
        Map<String, Object> map = elasticSearchService.getList(tagIds,caseName, pageNum, pageSize);
        return ResultUtil.success(map);
    }

    /**
     * 根据参数模糊匹配标签
     * @param tagNames
     * @return
     */
    @GetMapping("/getCaseTags")
    public ResponseVo getCaseTags(String tagNames){
        List<Map<String,Object>> list = dataDictItemMapper.getTagNames(tagNames);
        return ResultUtil.success(list);
    }

}
