package ink.wgink.module.instantmessage.controller.api;

import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.instantmessage.service.IWebSocketClientService;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: WebSocketClientController
 * @Description: WebSocket客户端
 * @Author: wanggeng
 * @Date: 2021/9/12 4:15 下午
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "websocket客户端")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/websocket/client")
public class WebSocketClientController {

    @Autowired
    private IWebSocketClientService webSocketClientService;

    @ApiOperation(value = "登录", notes = "登录接口，返回Socket认证token")
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("login/{clientName}")
    public SuccessResultData<String> login(@PathVariable("clientName") String clientName) {
        String sessionId = webSocketClientService.login(clientName);
        return new SuccessResultData<>(sessionId);
    }

}
