package com.lightinit.hsdataplatform.controller.admin;

import com.lightinit.hsdataplatform.entity.BaseExample;
import com.lightinit.hsdataplatform.model.admin.DownstreamListModel;
import com.lightinit.hsdataplatform.model.admin.DownstreamSearchModel;
import com.lightinit.hsdataplatform.service.admin.IDownstreamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping(value="/admin/Downstream")
public class DownstreamController extends BaseController {
    @Autowired
    private IDownstreamService downstreamService;
    @RequestMapping(value="/index.htm")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView("/admin/downstream/index");
        return modelAndView;
    }

    @RequestMapping(value = "list.action")
    public ModelAndView list(DownstreamSearchModel  inputModel, @RequestParam(defaultValue = "1") int pageNo) {
        ModelAndView modelAndView = new ModelAndView("admin/downstream/list");
        BaseExample.Page pager = new BaseExample.Page(pageNo, 10);
        inputModel.setPage(pager);
        List<DownstreamListModel> outputModel = downstreamService.queryList(inputModel);
        pager.setTotal(downstreamService.queryCount(inputModel));
        modelAndView.addObject("list", outputModel);
        modelAndView.addObject("pager", pager);
        return modelAndView;
    }

}
