/* * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. * * https://www.mall4j.com/ * * 未经允许,不可做商业用途! * * 版权所有,侵权必究! */ package com.yami.trading.security.common.controller; import com.yami.trading.security.common.bo.TokenInfoBO; import com.yami.trading.security.common.dto.RefreshTokenDTO; import com.yami.trading.security.common.manager.TokenStore; import com.yami.trading.security.common.vo.TokenInfoVO; import io.swagger.annotations.Api; import ma.glasnost.orika.MapperFacade; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; /** * @author 菠萝凤梨 * @date 2022/3/25 17:33 */ @RestController @CrossOrigin @Api(tags = "token") public class TokenController { @Autowired private TokenStore tokenStore; @Autowired private MapperFacade mapperFacade; @PostMapping("/token/refresh") public ResponseEntity refreshToken(@Valid @RequestBody RefreshTokenDTO refreshTokenDTO) { TokenInfoBO tokenInfoServerResponseEntity = tokenStore .refreshToken(refreshTokenDTO.getRefreshToken()); return ResponseEntity .ok(mapperFacade.map(tokenInfoServerResponseEntity, TokenInfoVO.class)); } }