package com.xhkjedu.slog.controller.log;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xhkjedu.model.slog.THandleLog;
import com.xhkjedu.slog.service.log.HandleLogService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.utils.PageUtil;
import com.xhkjedu.vo.PageResult;
import com.xhkjedu.vo.ResultVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Description：操作日志
 * @Author: WN
 * @Date: 2023/11/15 10:32:27
 **/
@RestController
@RequestMapping("/handlelog")
public class HandleLogController {
    @Resource
    private HandleLogService handleLogService;

    /*
     * @Description 操作日志-校园列表
     * @Date 2023/11/15 10:59:59
     * @Author WN
     * @Param [log]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/lists")
    public ResultVo listHandleLogForSchool(@RequestBody THandleLog log){
        Integer page = log.getPage();
        Integer pageSize = log.getPageSize();
        N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
        PageHelper.startPage(page, pageSize);
        List<THandleLog> logs = handleLogService.listHandleLogForSchool(log);
        PageResult pageResult = PageUtil.getPageResult(new PageInfo(logs));
        return new ResultVo(0, "获取操作日志列表成功", pageResult);
    }

    /*
     * @Description 操作日志-区域列表
     * @Date 2023/11/15 10:59:59
     * @Author WN
     * @Param [log]
     * @Return com.xhkjedu.vo.ResultVo
     **/
    @PostMapping("/listc")
    public ResultVo listHandleLogForCloud(@RequestBody THandleLog log){
        Integer page = log.getPage();
        Integer pageSize = log.getPageSize();
        N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
        PageHelper.startPage(page, pageSize);
        List<Map> logs = handleLogService.listHandleLogForCloud(log);
        PageResult pageResult = PageUtil.getPageResult(new PageInfo(logs));
        return new ResultVo(0, "获取操作日志列表成功", pageResult);
    }
}
