package com.weather.controller;


import com.weather.common.AjaxResult;
import com.weather.common.BaseController;
import com.weather.common.page.TableDataInfo;


import com.weather.entity.WeaFtpInfo;

import com.weather.service.IWeaFtpInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 产品存储ftp 前端控制器
 * </p>
 *
 * @author feng
 * @since 2023-09-05
 */
@RestController
@RequestMapping("weaFtpInfo")
public class WeaFtpInfoController extends BaseController {

    @Autowired
    private IWeaFtpInfoService weaFtpInfoService;


    /**
     * 模糊获取ftp列表
     */
    @ApiOperation(value = "模糊获取ftp列表")
    @GetMapping("/dimList")
    public TableDataInfo dimList(String ftpname)
    {
        startPage();
        List<WeaFtpInfo> list = weaFtpInfoService.selectWeaFtpInfoDim(ftpname);
        return getDataTable(list);
    }

    /**
     * 获取产品存储ftp列表
     */
    @ApiOperation(value = "获取产品存储ftp列表")
    @GetMapping("/list")
    public TableDataInfo list(WeaFtpInfo weaFtpInfo)
    {
        startPage();
        List<WeaFtpInfo> list = weaFtpInfoService.selectWeaFtpInfoList(weaFtpInfo);
        return getDataTable(list);
    }

    /**
     * 根据产品存储ftp编号获取详细信息
     */
    @ApiOperation(value = "根据编号获取详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return success(weaFtpInfoService.selectWeaFtpInfoById(id));
    }

    /**
     * 新增产品存储ftp
     */

    @ApiOperation(value = "新增产品存储ftp")
    @PostMapping
    public AjaxResult add(@Validated @RequestBody WeaFtpInfo weaFtpInfo)
    {

        weaFtpInfo.setStatus(0);
        return toAjax(weaFtpInfoService.insertWeaFtpInfo(weaFtpInfo));
    }

    /**
     * 修改产品存储ftp
     */

    @ApiOperation(value = "修改产品存储ftp")
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody WeaFtpInfo weaFtpInfo)
    {

        return toAjax(weaFtpInfoService.updateWeaFtpInfo(weaFtpInfo));
    }

    /**
     * 删除产品存储ftp
     */

    @ApiOperation(value = "删除产品存储ftp")
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(weaFtpInfoService.deleteWeaFtpInfoById(id));
    }

}

