package com.xindazhou.framework.common.biz.infra.logger;

import com.xindazhou.framework.common.biz.infra.logger.dto.LoginLogCreateReqDTO;
import com.xindazhou.framework.common.enums.RpcConstants;
import com.xindazhou.framework.common.pojo.CommonResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(name = RpcConstants.USER_NAME) // TODO 芋艿：fallbackFactory =
@Tag(name = "RPC 服务 - 登录日志")
public interface LoginLogCommonApi {

    String PREFIX = RpcConstants.USER_PREFIX + "/login-log";

    @PostMapping(PREFIX + "/create")
    @Operation(summary = "创建登录日志")
    CommonResult<Boolean> createLoginLog(@Valid @RequestBody LoginLogCreateReqDTO reqDTO);

    /**
     * 【异步】创建登录日志
     *
     * @param reqDTO 登录日志 DTO
     */
    @Async
    default void createLoginLogAsync(LoginLogCreateReqDTO reqDTO) {
        createLoginLog(reqDTO).checkError();
    }

}

