package com.lightinit.hsdatashow.controller.ms;

import com.lightinit.hsdatashow.controller.admin.BaseController;
import com.lightinit.hsdatashow.entity.AverageExpectedRate;
import com.lightinit.hsdatashow.entity.BaseExample;
import com.lightinit.hsdatashow.entity.PopulationSummary;
import com.lightinit.hsdatashow.model.ResultState;
import com.lightinit.hsdatashow.service.ms.IMSAverageExpectedRateService;
import com.lightinit.hsdatashow.service.ms.IMSPeopleGrowthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping(value = "/ms/AverageExpectedRate")
public class MSAverageExpectedRateController extends BaseController {
    @Autowired
    private IMSAverageExpectedRateService imsAverageExpectedRateService;
    /**
     * 跳转页面
     * @return
     */
    @RequestMapping("index.htm")
    public ModelAndView index () {
        ModelAndView modelAndView = new ModelAndView("ms/peopleGrowth/averagExpectedRate/index");
        return modelAndView;
    }

    /**
     * 查询列表
     * @param pageNo
     * @return
     */
    @RequestMapping("list.action")
    public ModelAndView list( @RequestParam(defaultValue = "1") int pageNo) {
        ModelAndView modelAndView = new ModelAndView("ms/peopleGrowth/averagExpectedRate/list");
        BaseExample.Page pager = new BaseExample.Page();
        pager.setPageNo(pageNo);
        List<AverageExpectedRate> outputModel = imsAverageExpectedRateService.queryList(pager);
        pager.setTotal(imsAverageExpectedRateService.queryCount(pager));
        modelAndView.addObject("list", outputModel);
        modelAndView.addObject("pager", pager);
        return modelAndView;
    }

    /**
     * 删除方法
     * @param id
     * @return
     */
    @RequestMapping(value = "del.action/{id}")
    @ResponseBody
    public ResultState delete(@PathVariable long id){
        ResultState<Long> resultState = imsAverageExpectedRateService.delete(id);
        return resultState;
    }

    /**
     * 添加方法
     * @param inputModel
     * @return
     */
    @RequestMapping(value = "add.action")
    @ResponseBody
    public ResultState doAdd(AverageExpectedRate inputModel){
        ResultState resultState = imsAverageExpectedRateService.add(inputModel);
        return resultState;
    }

    /**
     * 跳转添加页面
     * @return
     */
    @RequestMapping(value = "add.htm")
    public ModelAndView add(){
        ModelAndView modelAndView = new ModelAndView("ms/peopleGrowth/averagExpectedRate/add");
        return modelAndView;
    }
    /**
     * 跳转修改页面
     * @return
     */
    @RequestMapping(value = "edit.htm/{id}")
    public ModelAndView edit(@PathVariable long id){
        ModelAndView modelAndView = new ModelAndView("ms/peopleGrowth/averagExpectedRate/edit");
        AverageExpectedRate model = imsAverageExpectedRateService.edit(id);
        modelAndView.addObject("model",model);
        return modelAndView;
    }

    /**
     * 编辑方法
     * @param inputModel
     * @return
     */
    @RequestMapping(value = "doEdit.action")
    @ResponseBody
    public ResultState doEdit(AverageExpectedRate inputModel){
        ResultState resultState = imsAverageExpectedRateService.doEdit(inputModel);
        return resultState;
    }

}
