package com.yzt.airconditionersystem.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yzt.airconditionersystem.bean.Log;
import com.yzt.airconditionersystem.service.LogService;
import com.yzt.airconditionersystem.util.BasePageVoUtil;
import com.yzt.airconditionersystem.vo.BasePageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author TzZach
 * @since 2022-04-22 21:18
 */
@Controller
public class LogController {

    private static final String PREFIX = "log/";

    @Autowired
    private LogService logService;

    @GetMapping("log-list")
    public String logList() {
        return PREFIX + "log-list";
    }


    @GetMapping("/logPage")
    @ResponseBody
    public BasePageVo logPage(@RequestParam("page") Long page,
                              @RequestParam("limit") Long limit) {
        Page<Log> pageInfo = new Page<>(page, limit);
        pageInfo = logService.page(pageInfo, null);
        BasePageVo pageVo = BasePageVoUtil.getPageVo(pageInfo);
        return pageVo;
    }

}
