package org.springblade.gateway.common_gateway.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @Author: Silent
 * @Description
 * @Date: Created in 9:28 2021/11/24
 * @Modified By:
 */
@RestController
@AllArgsConstructor
@RequestMapping("app/index/census")
@Api(value = "统计在线人数", tags = "统计在线人数接口")
public class OnlineCensusController {

	/**
	 * 统计所有数量
	 */
	@GetMapping("/online")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "统计上线用户")
	public R<Long> online(HttpSession session){
		session.getId();
		return R.success("用户上线");
	}

	/**
	 * 统计所有数量
	 */
	@GetMapping("/offline")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "统计下线用户")
	public R<Long> offline(HttpSession session){
		session.invalidate();
		return R.success("用户下线");
	}
}
