package com.hs.api.controller;

import com.hs.api.common.Result;
import com.hs.api.model.DicIndInfo;
import com.hs.api.service.DicIndService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;


@Api(tags = "指标查询")
@RestController
public class IndController {

    @Autowired
    private DicIndService dicIndService;

//    @GetMapping
//    public ModelAndView index(Model model, String filter) {
//        model.addAttribute("title", "指标搜索");
//        model.addAttribute("indList", dicIndService.selectAll(filter));
//        model.addAttribute("filter", filter == null ? "" : filter);
//        ModelAndView mav = new ModelAndView("ind", "indModel", model);
//        return mav;
//    }
//
//    @PostMapping("search")
//    public ModelAndView search(String filter) {
//        return new ModelAndView("redirect:/ind?filter=" + filter);
//    }

    @GetMapping("ind/find")
    public Object find(Integer pageCode, String filter) {
        List<DicIndInfo> list = dicIndService.selectAll(pageCode, filter);
        return Result.success(list);
    }

}
