package com.huatek.busi.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.entity.SftpConnectConfig;
import com.huatek.busi.service.ISftpConnectConfigService;
import com.huatek.busi.vo.SftpConnectConfigVo;
import com.huatek.torch.frame.tools.ConstantUtil;
import com.huatek.torch.frame.tools.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags={"ftp连接配置管理接口"})
@RestController
@RequestMapping("/api/sftpConnectConfig")
public class SftpConnectConfigController {

    @Reference(check = false)
    ISftpConnectConfigService sftpConnectConfigService;

    @ApiOperation(value = "显示sftp连接配置",httpMethod="POST", notes= "显示sftp连接配置", produces = "application/json;charset=utf-8", response= Map.class)
    @PostMapping(value = "/list", produces = { "application/json;charset=utf-8" })
    public Map<String, Object> findOne(){
        SftpConnectConfig sftpConnectConfig = sftpConnectConfigService.findOne();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "BUSINESS.QUERY.SUCCESS", sftpConnectConfig);
    }

    @ApiOperation(value = "新增或更新sftp连接配置",httpMethod="POST", notes= "新增或更新sftp连接配置", produces = "application/json;charset=utf-8", response= Map.class)
    @PostMapping(value = "/saveOrUpdate", produces = { "application/json;charset=utf-8" })
    public Map<String, Object> saveOrUpdate(@RequestHeader("token") String token, @RequestBody SftpConnectConfigVo sftpConnectConfigVo){
        return sftpConnectConfigService.saveOrUpdate(token, sftpConnectConfigVo);
    }
}
