package com.sonic.bear.controller.api;

import com.sonic.bear.domain.input.TouchSessionInput;
import com.sonic.bear.service.UserSessionService;
import com.sonic.common.auth.domains.Session;
import com.sonic.common.log.IgnoreRequestLog;
import com.sonic.common.rpc.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;

/**
 * API-Session获取
 * @author coder
 */
@Validated
@RestController
public class UserSessionApi {

    @Autowired
    private UserSessionService userSessionService;

    @ApiOperation(value = "token验证", tags = {"API-Session获取"})
    @PostMapping("/api/auth/touch-session")
    @IgnoreRequestLog(types = IgnoreRequestLog.IgnoreType.SILENT)
    public Result<Session> touchSession(@RequestBody @Valid TouchSessionInput input) {
        return Result.success(userSessionService.touchSession(input.getToken()));
    }

}
