package com.hs.api.controller;

import com.hs.api.service.DicIndService;
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.servlet.ModelAndView;
import springfox.documentation.annotations.ApiIgnore;


@ApiIgnore
@RequestMapping("ind")
@Controller
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);
    }

}
