package com.gyee.wisdom.alarm.sharding.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gyee.wisdom.alarm.sharding.entity.Scadabj;
import com.gyee.wisdom.alarm.sharding.entity.Scadafault;
import com.gyee.wisdom.alarm.sharding.service.ScadabjService;
import com.gyee.wisdom.alarm.sharding.service.ScadafaultService;
import com.gyee.wisdom.alarm.sharding.util.UserLoginToken;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/scadafault")
@CrossOrigin
public class ScadafaultController {

    @Autowired
    private ScadafaultService scadafaultService;

    //@UserLoginToken
    @PostMapping(value = "/save")
    public int saveScadafault( Scadafault scadafault){
        return scadafaultService.saveAndUpdateScadafault(scadafault);
    }

    @DeleteMapping(value = "/delete")
    public int deleteScadafault( Scadafault scadafault){
        return scadafaultService.deleteScadafault(scadafault);
    }

    //@UserLoginToken
    @GetMapping(value = "/page")
    public IPage<Scadafault> queryByPage(
            @RequestParam(value = "pagenum")Integer pageNum,
            @RequestParam(value = "pagesize")Integer pageSize
    ){
        Page<Scadafault> page =new Page(pageNum,pageSize);
        return  scadafaultService.pageQueryAll(page);
    }
}
