package com.lightinit.hsdataplatform.controller.admin;

import com.lightinit.hsdataplatform.dictionary.DicLeaveMessageState;
import com.lightinit.hsdataplatform.entity.BaseExample;
import com.lightinit.hsdataplatform.entity.RunningMonitoringLog;
import com.lightinit.hsdataplatform.model.admin.LeaveMessageListModel;
import com.lightinit.hsdataplatform.model.admin.LeaveMessageSearchModel;
import com.lightinit.hsdataplatform.model.admin.LoggerSearchModel;
import com.lightinit.hsdataplatform.service.admin.ILoggerMoniterService;
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.servlet.ModelAndView;

import java.util.List;

/**
 * @Author: sunxiang
 * @Date: 2019/3/17 14:25
 * @Description:
 **/
@Controller
@RequestMapping("/admin/loggerMoniter")
public class LoggerMoniterController {

    @Autowired
    private ILoggerMoniterService loggerMoniterService;

    /////////////////////////////////////////////////////////用户日志监控
    @RequestMapping(value = "index.htm")
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("admin/loggerMoniter/index");
        return modelAndView;
    }

    @RequestMapping(value = "list.action")
    public ModelAndView list(LoggerSearchModel inputModel, @RequestParam(defaultValue = "1") int pageNo){
        ModelAndView modelAndView = new ModelAndView("admin/loggerMoniter/list");
        BaseExample.Page pager = new BaseExample.Page();
        pager.setPageNo(pageNo);
        inputModel.setPage(pager);
        inputModel.setType("用户日志监控");
        List<RunningMonitoringLog> list=loggerMoniterService.getList(inputModel);
        pager.setTotal(loggerMoniterService.getListCount(inputModel));
        modelAndView.addObject("outputModel",list);
        modelAndView.addObject("pager",pager);
        return modelAndView;
    }

    @RequestMapping(value = "detail.htm/{id}")
    public ModelAndView detail(@PathVariable Long id){
        ModelAndView modelAndView = new ModelAndView("admin/loggerMoniter/detail");
        modelAndView.addObject("model",loggerMoniterService.getDetail(id));
        return modelAndView;
    }


   ///////////////////////////////////////////////////////运行状态监控

    @RequestMapping(value = "yunxingindex.htm")
    public ModelAndView yunxingindex(){
        ModelAndView modelAndView = new ModelAndView("admin/loggerMoniter/yunxingindex");
        return modelAndView;
    }

    @RequestMapping(value = "yunxinglist.action")
    public ModelAndView yunxinglist(LoggerSearchModel inputModel, @RequestParam(defaultValue = "1") int pageNo){
        ModelAndView modelAndView = new ModelAndView("admin/loggerMoniter/list");
        BaseExample.Page pager = new BaseExample.Page();
        pager.setPageNo(pageNo);
        inputModel.setPage(pager);
        inputModel.setType("运行状态监控");
        List<RunningMonitoringLog> list=loggerMoniterService.getList(inputModel);
        pager.setTotal(loggerMoniterService.getListCount(inputModel));
        modelAndView.addObject("outputModel",list);
        modelAndView.addObject("pager",pager);
        return modelAndView;
    }

    /*@RequestMapping(value = "yunxingdetail.htm/{id}")
    public ModelAndView deyunxingdetailtail(@PathVariable Long id){
        ModelAndView modelAndView = new ModelAndView("admin/loggerMoniter/yunxingdetail");
        modelAndView.addObject("model",loggerMoniterService.getDetail(id));
        return modelAndView;
    }*/

    ////////////////////////////////////////////////////////运行流量监控

    @RequestMapping(value = "liuliangindex.htm")
    public ModelAndView liuliangindex(){
        ModelAndView modelAndView = new ModelAndView("admin/loggerMoniter/liuliangindex");
        return modelAndView;
    }

    @RequestMapping(value = "liulianglist.action")
    public ModelAndView liulianglist(LoggerSearchModel inputModel, @RequestParam(defaultValue = "1") int pageNo){
        ModelAndView modelAndView = new ModelAndView("admin/loggerMoniter/list");
        BaseExample.Page pager = new BaseExample.Page();
        pager.setPageNo(pageNo);
        inputModel.setPage(pager);
        inputModel.setType("运行流量监控");
        List<RunningMonitoringLog> list=loggerMoniterService.getList(inputModel);
        pager.setTotal(loggerMoniterService.getListCount(inputModel));
        modelAndView.addObject("outputModel",list);
        modelAndView.addObject("pager",pager);
        return modelAndView;
    }

   /* @RequestMapping(value = "liuliangdetail.htm/{id}")
    public ModelAndView liuliangdetail(@PathVariable Long id){
        ModelAndView modelAndView = new ModelAndView("admin/loggerMoniter/liuliangdetail");
        modelAndView.addObject("model",loggerMoniterService.getDetail(id));
        return modelAndView;
    }*/
}
