package com.lutao.cloud.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lutao.cloud.admin.api.feign.RemoteTokenService;
import com.lutao.cloud.common.core.constant.SecurityConstants;
import com.lutao.cloud.common.core.util.MessageInfo;
import com.lutao.cloud.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**

 * @date 2018/9/4 getTokenPage 管理
 */
@Api(value = "/token", tags ={"token管理"})
@RestController
@AllArgsConstructor
@RequestMapping("/token")
public class SysTokenController{

	private final RemoteTokenService remoteTokenService;

	/**
	 * 分页token 信息
	 * @param params 参数集
	 * @return token集合
	 */
	@ApiOperation(value = "分页token 信息", notes = "分页token 信息", httpMethod = "GET")
	@GetMapping("/page")
	public MessageInfo<Page> getTokenPage(@RequestParam Map<String, Object> params){
		// 获取请求的
		return remoteTokenService.getTokenPage(params, SecurityConstants.FROM_IN);
	}

	/**
	 * 删除
	 * @param token getTokenPage
	 * @return success/false
	 */
	@ApiOperation(value = "删除", notes = "删除", httpMethod = "DELETE")
	@SysLog("删除用户token")
	@DeleteMapping("/{token}")
//	@PreAuthorize("@pms.hasPermission('sys_token_del')")
	public MessageInfo<Boolean> removeById(@PathVariable String token){
		return remoteTokenService.removeTokenById(token, SecurityConstants.FROM_IN);
	}

}
