package com.community.huiju.controller;

import com.community.commom.constant.Constant;
import com.community.commom.mode.ResponseBean;
import com.community.commom.session.UserElement;
import com.community.huiju.service.IVisualIntercomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RefreshScope
@RequestMapping("/")
@Api(value = "可视对讲 API", description = "可视对讲 API")
public class VisualIntercomContrller extends BaseController {

    @Autowired
    private IVisualIntercomService iVisualIntercomService;

    @ApiOperation(value = "门口机开门", notes = "门口机开门")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "header", name = "X-Auth-Token", value = "token")
    })
    @RequestMapping(value = "/visual/syncControl", method = RequestMethod.GET)
    public ResponseBean syncControl(HttpServletRequest request, HttpSession session){
        ResponseBean responseBean = new ResponseBean();
        UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
        responseBean = iVisualIntercomService.syncControl(userElement);
        return responseBean;
    }


}
