package com.gtiit.shr.controller;

import com.github.pagehelper.PageInfo;
import com.gtiit.shr.common.QueryPageBean;
import com.gtiit.shr.common.ResponseResult;
import com.gtiit.shr.common.Result;
import com.gtiit.shr.entity.vo.ExceptionRequestVo;
import com.gtiit.shr.service.ExceptionService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/exception"})
@CrossOrigin
public class ExceptionController {
    @Autowired
    ExceptionService exceptionService;


    @RequestMapping({"insert"})
    public Result insertException(@RequestBody ExceptionRequestVo exceptionRequestVo) {
        int result = this.exceptionService.insertException(exceptionRequestVo);
        return result == 0 ? ResponseResult.isError("异常记录保存失败！", (Object)null) : ResponseResult.isOk("异常记录保存成功！", (Object)null);
    }

    @RequestMapping({"/insertBatch"})
    public Result insertBatchException(@RequestBody List<ExceptionRequestVo> exceptionRequestVos) {
        int result = this.exceptionService.insertBatchException(exceptionRequestVos);
        return result == 0 ? ResponseResult.isError("异常记录保存失败！", (Object)null) : ResponseResult.isOk("异常记录保存成功！", (Object)null);
    }

    @RequestMapping({"/findPage"})
    public Result findPage(@RequestBody QueryPageBean queryPageBean) {
        try {
            PageInfo<ExceptionRequestVo> page = this.exceptionService.findPage(queryPageBean);
            return ResponseResult.isOk("异常记录查询成功", page);
        } catch (Exception var3) {
            return ResponseResult.isError("异常记录查询失败！", var3.getMessage());
        }
    }
}
