package com.xindazhou.business.api.logger;

import com.xindazhou.framework.common.biz.infra.logger.ApiErrorLogCommonApi;
import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.framework.common.biz.infra.logger.dto.ApiErrorLogCreateReqDTO;
import com.xindazhou.business.service.logger.ApiErrorLogService;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Primary;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.xindazhou.framework.common.biz.infra.logger.ApiErrorLogCommonApi.PREFIX;
import static com.xindazhou.framework.common.pojo.CommonResult.success;

/**
 * API 异常日志 CommonApi 实现类
 * 
 * 提供 HTTP 接口供其他服务通过 Feign 调用
 * 
 * @author xindazhou
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@RequestMapping(PREFIX) // 添加 @RequestMapping 以暴露 RPC 接口
@Validated
@Primary // 由于 ApiErrorLogCommonApi 的存在，必须声明为 @Primary Bean
public class ApiErrorLogApiImpl implements ApiErrorLogCommonApi {

    @Resource
    private ApiErrorLogService apiErrorLogService;

    @Override
    public CommonResult<Boolean> createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
        apiErrorLogService.createApiErrorLog(createDTO);
        return success(true);
    }

}

