package com.railway.web.controller.business.safetool;

import com.railway.business.safetool.domain.SecScheduledTool;
import com.railway.business.safetool.service.ISecScheduledToolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.WebDataBinder;
import com.railway.common.core.controller.BaseController;
import com.railway.common.core.domain.AjaxResult;
import com.railway.common.core.page.TableDataInfo;
import javax.validation.Valid;
import java.util.List;

import javax.validation.Valid;

//@Api(value = "rest/safetool/sec/scheduled/tool", tags = "安全计划和工具关系表")
@RestController
@Validated
@RequestMapping(value = "business/safetool/sec/scheduled/tool")
public class SecScheduledToolController extends BaseController {
    @Autowired
    private ISecScheduledToolService secScheduledToolService;

    @ApiOperation(value = "新增")
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody SecScheduledTool secScheduledTool) {
        return toAjax(secScheduledToolService.create(secScheduledTool));
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("/{ids}")
    public AjaxResult delete(@RequestParam String[] ids) {
        return toAjax(secScheduledToolService.delete(ids));
    }

    @ApiOperation(value = "更新")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody @Valid SecScheduledTool secScheduledTool) {
        return toAjax(secScheduledToolService.update(secScheduledTool));
    }

    @ApiOperation(value = "单个")
    @GetMapping(value = {"/", "/{id}"})
    public AjaxResult getInfo(String id) {
        SecScheduledTool info = secScheduledToolService.getInfo(id);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("info",info);
        return ajax;
    }

    @ApiOperation(value = "列表")
    @GetMapping(value = "list")
    public TableDataInfo getList(SecScheduledTool secScheduledTool) {
        startPage();
        List<SecScheduledTool> list = secScheduledToolService.getList(secScheduledTool);
        return getDataTable(list);
    }

}
