package com.nantian.cloud.dbcapp.controller;


import com.nantian.cloud.dbcapp.entity.ExceptionTypeModel;
import com.nantian.cloud.dbcapp.service.ExceptionTypeService;
import com.nantian.sc.cloud.common.core.util.R;
import com.nantian.sc.cloud.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
* @Description: 异常分类controller
* @Param: 
* @return: 
* @Author: zfw
* @Date: 2021/02/22
* @Date: 15:30
*/
@CrossOrigin
@RestController
@AllArgsConstructor
@RequestMapping("/exceptionType")
@Api(value = "exceptionType", tags = "异常分类")

public class ExceptionTypeController {

    private final ExceptionTypeService exceptionService;


    /**
     * 查询列表
     *
     * @param
     * @return R
     */
    @GetMapping("/list")
    @SysLog("异常分类-查询列表")
    @ApiOperation(value = "查询列表", notes = "查询列表")
    public R getTotal() {
        return R.ok(exceptionService.getList(),"查询成功");
    }

    /**
     * 添加或修改
     *
     * @param
     * @return R
     */
    @PostMapping("/addOrUpdate")
    @SysLog("异常分类-添加或修改")
    @ApiOperation(value = "添加或修改", notes = "添加或修改")
    public R addOrUpdate(@Valid @RequestBody ExceptionTypeModel exceptionTypeModel) {
        return exceptionService.addOrUpdate(exceptionTypeModel);
    }

    /**
     * 删除
     *
     * @param
     * @return R
     */
    @DeleteMapping("/deleteById")
    @SysLog("异常分类-删除")
    @ApiOperation(value = "删除", notes = "删除")
    public R deleteById(Integer id) {
        return exceptionService.deleteById(id);
    }


}
