package com.xhkjedu.sapi.controller.system;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xhkjedu.annotation.Action;
import com.xhkjedu.sapi.model.system.TSyserror;
import com.xhkjedu.sapi.service.system.SyserrorService;
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;

/**
* @author ywx
* @classname TSyserrorController
* @description
* @date 2020/10/09 15:13
**/
@RestController
@RequestMapping("/syserror")
public class SyserrorController {
    @Resource
    private SyserrorService syserrorService;

    @PostMapping("/add")
    @Action("系统错误-增加")
    public ResultVo add(@RequestBody TSyserror error) {
        Integer id = syserrorService.save(error);
        return new ResultVo(0, "保存成功",id);
    }

    @PostMapping("/list")
    public ResultVo list(@RequestBody TSyserror error) {
        PageHelper.startPage(error.getPage(), error.getPageSize());
        List<TSyserror> list = syserrorService.listAll(error);
        PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
        return new ResultVo(0,"获取系统错误列表成功",pageResult);
    }
}
