package com.lightinit.hsdataplatform.controller.admin;

import com.lightinit.hsdataplatform.dictionary.DicResourceMicroappState;
import com.lightinit.hsdataplatform.entity.BaseExample;
import com.lightinit.hsdataplatform.model.admin.ResourceCountListModel;
import com.lightinit.hsdataplatform.model.admin.ResourceCountSearchModel;
import com.lightinit.hsdataplatform.service.admin.IResourceCountService;
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/ResourceCount")
public class ResourceCountController extends BaseController {
    @Autowired
    private IResourceCountService resourceCountService;
    @RequestMapping(value="index.htm")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView("admin/access_statistics/resourceCount");
        return modelAndView;
    }

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