package com.nbclass.activity.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nbclass.system.controller.BaseController;
import com.nbclass.system.model.SysLog;
import com.nbclass.system.service.SysLogService;
import com.nbclass.util.CommonUtils;
import com.nbclass.util.PageUtil;
import com.nbclass.util.ResultUtil;
import com.nbclass.vo.base.PageResultVo;

/**
 * i系统日志
 * @author Leon
 * @datetime 2020年6月3日 下午5:28:24
 */
@Controller
@RequestMapping("/console/syslog")
public class SysLogController extends BaseController {

    @Resource
    private SysLogService service;

    /**
     * i查询列表页面
     * @param model
     * @return
     */
    @GetMapping("/index")
    public String indexPage(){
        return "syslog/list";
    }
    
    /**
     * i查询数据列表
     * @param entity
     * @param limit
     * @param offset
     * @return
     */
    @PostMapping("/list")
    @ResponseBody
    public PageResultVo getList(SysLog entity, Integer limit, Integer offset){
        PageHelper.startPage(PageUtil.getPageNo(limit, offset),limit);
        List<SysLog> userList = service.getList(entity);
        PageInfo<SysLog> pages = new PageInfo<>(userList);
        return ResultUtil.table(userList,pages.getTotal());
    }

    /**
     * i删除数据
     * @param ids
     */
    @PostMapping("/delete")
    @ResponseBody
    public void delete(String ids) {
        List<Long> IdList = CommonUtils.toLongList(ids);
        service.delete(IdList);
        outPrint();
    }

}
