package com.liquidnet.service.goblin.controller;

import com.liquidnet.service.goblin.service.IGoblinMailTrackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 快递100地图订阅回调
 */
@Slf4j
@Api(tags = "快递100回调")
@RestController
@RequestMapping("/callback/kuaidi100")
public class GoblinKuaidi100CallbackController {

    @Autowired
    private IGoblinMailTrackService goblinMailTrackService;

    @PostMapping("/map")
    @ApiOperation("地图轨迹订阅推送回调")
    public Map<String, Object> mapCallback(@RequestParam(value = "param", required = false) String param,
                                           @RequestParam(value = "sign", required = false) String sign,
                                           @RequestParam(value = "mailId", required = false) String mailId,
                                           @RequestParam(value = "orderId", required = false) String orderId) {
        log.info("[kuaidi100-callback] mailId={}, orderId={}, sign={}", mailId, orderId, sign);
        return goblinMailTrackService.handleCallback(param, sign, mailId, orderId);
    }
}
