/*
 * Create by Kinoko
 * 18-5-16 下午2:38
 */

package com.kinoko.graduationdesign.controller;


import com.kinoko.graduationdesign.entity.LeaveTable;
import com.kinoko.graduationdesign.entity.Result;
import com.kinoko.graduationdesign.entity.User;
import com.kinoko.graduationdesign.service.LeaveTableService;
import com.kinoko.graduationdesign.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class LeaveTableController {

    @Autowired
    private LeaveTableService leaveTableService;

    @GetMapping("/api/getAllLeave")
    public Result getAllUser(@RequestParam("page") int page) {
        Page<LeaveTable> leaveTablePage = leaveTableService.getAllLeave(page);
        List<LeaveTable> leaveTableList = leaveTablePage.getContent();
        int totalPages = leaveTablePage.getTotalPages();
        if (leaveTableList.size() == 0) {
            return ResultUtil.error("没有数据");
        } else {
            return ResultUtil.success(totalPages, leaveTableList);
        }
    }


}
