package com.lightinit.hsdataplatform.controller.admin;

import com.lightinit.hsdataplatform.entity.BaseExample;
import com.lightinit.hsdataplatform.model.admin.UserCountListModel;
import com.lightinit.hsdataplatform.model.admin.UserCountSearchModel;
import com.lightinit.hsdataplatform.service.admin.IUserCountService;
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/UserCount")
public class UserCountController extends BaseController {
    @Autowired
    private IUserCountService userCountService;
    @RequestMapping(value="index.htm")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView("admin/access_statistics/userCount");
        return modelAndView;
    }

    @RequestMapping(value = "list.action")
    public ModelAndView list(UserCountSearchModel inputModel, @RequestParam(defaultValue = "1") int pageNo) {
        ModelAndView modelAndView = new ModelAndView("admin/access_statistics/userCountList");
        BaseExample.Page pager = new BaseExample.Page();
        pager.setPageNo(pageNo);
        inputModel.setPage(pager);
        List<UserCountListModel> outputModel = userCountService.queryList(inputModel);
        pager.setTotal(userCountService.queryCount(inputModel));
        modelAndView.addObject("list", outputModel);
        modelAndView.addObject("pager", pager);
        return modelAndView;
    }
}
