package org.springblade.flow.base.controller;

import java.util.List;

import org.springblade.flow.base.ActionResult;
import org.springblade.flow.base.Page;
import org.springblade.flow.base.service.UserOnlineService;
import org.springblade.flow.message.model.UserOnlineModel;
import org.springblade.flow.message.model.UserOnlineVO;
import org.springblade.flow.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 在线用户
 *
 * @author JNPF开发平台组
 * @version V3.1.0
 * @copyright 引迈信息技术有限公司
 * @date 2019年9月26日 上午9:18
 */
@Api(tags = "Online", value = "在线用户")
@RestController
@RequestMapping("/paas/system/OnlineUser")
public class UserOnlineController {

	@Autowired
	private UserOnlineService userOnlineService;

	/**
	 * 列表
	 *
	 * @param page
	 * @return
	 */
	@ApiOperation("获取在线用户列表")
	@GetMapping
	public ActionResult list(Page page) {
		List<UserOnlineModel> data = userOnlineService.getList(page);
		List<UserOnlineVO> vo = JsonUtil.getJsonToList(data, UserOnlineVO.class);
		return ActionResult.success(vo);
	}

	/**
	 * 注销
	 *
	 * @param id 主键值
	 * @return
	 */
	@ApiOperation("强制下线")
	@DeleteMapping("/{id}")
	public ActionResult delete(@PathVariable("id") String id) {
		userOnlineService.delete(id);
		return ActionResult.success("操作成功");
	}
}
