package com.sino.mci.channel.wecom.sync;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 企业微信同步客户端的 mock 实现。
 *
 * <p>不发起真实企微 API 调用，仅返回固定样例数据，供开发与测试使用。</p>
 */
@Component
@ConditionalOnProperty(name = "mci.wecom.sync.mock", havingValue = "true")
public class MockWeComSyncClient implements WeComSyncClient {

    @Override
    public List<WeComContact> syncEnterpriseContacts(WeComSyncConfig config) {
        return List.of(
                WeComContact.builder()
                        .userId("user001")
                        .name("张三")
                        .mobile("13800138001")
                        .type(WeComContactType.INTERNAL)
                        .departmentIds(List.of(1L, 2L))
                        .build()
        );
    }

    @Override
    public List<WeComContact> syncAccountContacts(WeComSyncConfig config, String userId) {
        return List.of(
                WeComContact.builder()
                        .userId("wmexternal001")
                        .name("客户李四")
                        .mobile("13900139001")
                        .type(WeComContactType.EXTERNAL)
                        .build()
        );
    }

    @Override
    public List<WeComConversation> syncAccountConversations(WeComSyncConfig config, String userId) {
        return List.of(
                WeComConversation.builder()
                        .chatId("chat001")
                        .chatName("测试客户群")
                        .ownerUserId(userId)
                        .memberList(List.of(
                                WeComConversationMember.builder()
                                        .userId(userId)
                                        .name("张三")
                                        .build(),
                                WeComConversationMember.builder()
                                        .userId("wmexternal001")
                                        .name("客户李四")
                                        .build()
                        ))
                        .build()
        );
    }
}
