package com.gyee.frame.controller.app.TargetDetail;

import com.gyee.frame.netty.websocket.util.SocketToolController;
import com.gyee.frame.service.app.targetdetail.TargetdetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author Wang Jiawen
 * @purpose
 * @date 2020-05-14 21:52
 */
@Controller
@RequestMapping("/targetdetail")
public class TargetdetailController extends SocketToolController {
    @Autowired
    private TargetdetailService targetdetailService;

    @ResponseBody
    @RequestMapping("/targetdetail_target")
    public String targetdetail(HttpServletRequest httpServletRequest,String pointKey) throws Exception {
            String remoteAddr = httpServletRequest.getRemoteAddr();
        Map<String, String> pointMap = TargetdetailService.targetdetail_target_pointMap;
        pointMap.put(remoteAddr,pointKey);
        TargetdetailService.targetdetail_target_pointMap = pointMap;
        return remoteAddr;
    }

    @ResponseBody
    @RequestMapping("/targetdetail_curve")
    public String targetdetail_curve(HttpServletRequest httpServletRequest,String pointKey) throws Exception {
        String remoteAddr = httpServletRequest.getRemoteAddr();
        Map<String, String> pointMap = TargetdetailService.targetdetail_curve_pointMap;
        pointMap.put(remoteAddr,pointKey);
        TargetdetailService.targetdetail_curve_pointMap = pointMap;
        return remoteAddr;
    }

    @ResponseBody
    @RequestMapping("/targetdetail_histogram")
    public String targetdetail_histogram(HttpServletRequest httpServletRequest,String pointKey) throws Exception {
        String remoteAddr = httpServletRequest.getRemoteAddr();
        Map<String, String> pointMap = TargetdetailService.targetdetail_histogram_pointMap;
        pointMap.put(remoteAddr,pointKey);
        TargetdetailService.targetdetail_histogram_pointMap = pointMap;
        return remoteAddr;
    }


    @ResponseBody
    @RequestMapping("/close_targetdetail_target")
    public String close_targetdetail(HttpServletRequest httpServletRequest,String pointKey) throws Exception {
        String remoteAddr = httpServletRequest.getRemoteAddr();
        Map<String, String> pointMap = TargetdetailService.targetdetail_target_pointMap;
        pointMap.remove(remoteAddr);
        TargetdetailService.targetdetail_target_pointMap = pointMap;
        return remoteAddr;
    }

    @ResponseBody
    @RequestMapping("/close_targetdetail_curve")
    public String close_targetdetail_curve(HttpServletRequest httpServletRequest,String pointKey) throws Exception {
        String remoteAddr = httpServletRequest.getRemoteAddr();
        Map<String, String> pointMap = TargetdetailService.targetdetail_curve_pointMap;
        pointMap.remove(remoteAddr);
        TargetdetailService.targetdetail_curve_pointMap = pointMap;
        return remoteAddr;
    }

    @ResponseBody
    @RequestMapping("/close_targetdetail_histogram")
    public String close_targetdetail_histogram(HttpServletRequest httpServletRequest,String pointKey) throws Exception {
        String remoteAddr = httpServletRequest.getRemoteAddr();
        Map<String, String> pointMap = TargetdetailService.targetdetail_histogram_pointMap;
        pointMap.remove(remoteAddr);
        TargetdetailService.targetdetail_histogram_pointMap = pointMap;
        return remoteAddr;
    }

}
