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

import com.railway.business.baseinfo.domain.BasePreventThaw;
import com.railway.business.baseinfo.service.IBasePreventThawService;
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/baseinfo/base/prevent/thaw", tags = "基础数据-九防台账-防春融")
@RestController
@Validated
@RequestMapping(value = "business/baseinfo/base/prevent/thaw")
public class BasePreventThawController extends BaseController {
    @Autowired
    private IBasePreventThawService basePreventThawService;

    @ApiOperation(value = "新增")
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody BasePreventThaw basePreventThaw) {
        return toAjax(basePreventThawService.create(basePreventThaw));
    }

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

    @ApiOperation(value = "更新")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody @Valid BasePreventThaw basePreventThaw) {
        return toAjax(basePreventThawService.update(basePreventThaw));
    }

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

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

}
