package com.community.huiju.controller;

import com.community.commom.constant.Constant;
import com.community.commom.mode.HkResponseBean;
import com.community.commom.mode.ResponseBean;
import com.community.commom.session.UserElement;
import com.community.huiju.model.HkVisitorBill;
import com.community.huiju.service.IHKService;
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.*;

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

/**
 * @author FXF
 * @date 2019-01-23
 */
@RestController
@RefreshScope
@RequestMapping("/")
@Api(value = "海康相关的API",description = "海康相关的API")
public class HkController extends BaseController {

	@Autowired
	private IHKService ihkService;

	@ApiOperation(value = "发送访客账单", notes = "发送访客账单")
	@ApiImplicitParams({ @ApiImplicitParam(paramType = "body", name = "hkVisitorBill", dataType = "String",value = "billNum: 账单号,reservationNum:预约单号,plateNum:出场车牌号,leaveTime:出场时间,billFee:账单金额")})
	@RequestMapping(value = "/sendVisitorBill",method = RequestMethod.POST)
	public HkResponseBean allMessageRead(@RequestBody HkVisitorBill hkVisitorBill){
		HkResponseBean hkResponseBean = new HkResponseBean();
		System.out.println("测试："+hkVisitorBill.getBillFee());
		System.out.println("测试："+hkVisitorBill.getBillNum());
		System.out.println("测试："+hkVisitorBill.getPlateNum());
		System.out.println("测试："+hkVisitorBill.getReservationNum());
		System.out.println("测试："+hkVisitorBill.getLeaveTime());
		hkResponseBean.addSuccess("账单发送成功","");
		return hkResponseBean;
	}

	@RequestMapping(value = "/pushHKPerson/{appUserId}", method = RequestMethod.POST)
	public ResponseBean pushHKPerson(@PathVariable("appUserId") String appUserId, @RequestParam("userVerifyId") Integer userVerifyId) {
		ResponseBean responseBean = new ResponseBean();
		responseBean = ihkService.pushPerson(appUserId, userVerifyId);
		return responseBean;
	}

	@Deprecated
	@RequestMapping(value = "/downloadAuthorityByDeviceUuids", method = RequestMethod.POST)
	public ResponseBean pushHKPerson() {
		ResponseBean responseBean = new ResponseBean();
		responseBean = ihkService.downloadAuthorityByDeviceUuids();
		return responseBean;
	}

	@ApiOperation(value = "门口机开门", notes = "门口机开门")
	@ApiImplicitParams({
			@ApiImplicitParam(dataTypeClass = Integer.class, paramType = "header", name = "X-Auth-Token", value = "用户审核房产id")
	})
	@RequestMapping(value = "/visual/syncControl", method = RequestMethod.POST)
	public ResponseBean syncControl( HttpServletRequest request, HttpSession session){
		ResponseBean responseBean = new ResponseBean();
		UserElement userElement = getUserElement(session);
		responseBean = ihkService.syncControl(userElement.getUserVerifyId());
		return responseBean;
	}


}
