package com.xindazhou.business.framework.rpc.config;

import com.xindazhou.business.api.config.ConfigApi;
import com.xindazhou.business.api.file.FileApi;
import com.xindazhou.business.api.member.MemberGroupApi;
import com.xindazhou.business.api.member.MemberLevelApi;
import com.xindazhou.business.api.member.MemberTagApi;
import com.xindazhou.business.api.member.MemberUserApi;
import com.xindazhou.business.api.websocket.WebSocketSenderApi;
import com.xindazhou.framework.common.biz.system.oauth2.OAuth2TokenCommonApi;
import com.xindazhou.framework.common.biz.system.permission.PermissionCommonApi;
import com.xindazhou.framework.security.core.rpc.LoginUserRequestInterceptor;
import com.xindazhou.user.api.permission.MenuApi;
import com.xindazhou.user.api.permission.RoleApi;
import com.xindazhou.message.api.MessageSendApi;
import com.xindazhou.vehicle.api.VehicleApi;
import com.xindazhou.vehicle.api.VehicleAlarmApi;
import com.xindazhou.vehicle.api.VehicleBindApi;
import com.xindazhou.vehicle.api.VehicleStatusApi;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(value = "systemRpcConfiguration", proxyBeanMethods = false)
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, ConfigApi.class,
        com.xindazhou.business.api.service.EvaluationApi.class,
        com.xindazhou.business.api.service.MaintenanceOrderApi.class, 
        MemberTagApi.class, MemberLevelApi.class, MemberGroupApi.class, MemberUserApi.class,
        com.xindazhou.user.api.user.MemberUserApi.class, OAuth2TokenCommonApi.class, PermissionCommonApi.class, 
        MenuApi.class, RoleApi.class, VehicleApi.class, VehicleAlarmApi.class, VehicleBindApi.class, VehicleStatusApi.class, MessageSendApi.class}) // 添加用户服务的 RPC 客户端（权限、菜单、角色）
public class RpcConfiguration {

    /**
     * LoginUser 请求拦截器
     * 用于在 Feign 调用时传递用户信息到目标服务
     */
    @Bean
    public LoginUserRequestInterceptor loginUserRequestInterceptor() {
        return new LoginUserRequestInterceptor();
    }

    // ServiceJwtRequestInterceptor 已由 ServiceJwtAutoConfiguration 自动配置，无需手动注册
}
