package com.jiayue.insu.incloud.controller;

import cn.hutool.json.JSONObject;
import com.jiayue.insu.incloud.constants.CommonStant;
import com.jiayue.insu.incloud.entity.Station;
import com.jiayue.insu.incloud.pushdata.PushDataToSftp;
import com.jiayue.insu.incloud.service.StationService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


/**
 * StationController
 *
 * @author yh
 * @date 2022-03-18 15:48:48
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/postTest")
public class PostTest {

    @Autowired
    public PushDataToSftp pushDataToSftp;
    @Autowired
    public StationService stationService;

    /**
     * @param
     * @return
     */
    @PostMapping("/test")
    public JSONObject test(String stationCode) {
        //校验授权信息并返回用户名及密码
        JSONObject result = new JSONObject();
        result.set("result", "success");
        Station station = stationService.checkAndFindStation(stationCode, CommonStant.RECORD_TYPE_PUSH_INIT);
        pushDataToSftp.pushDQAndNWPData(station);
        return result;
    }
}
