package com.hxhq;

import com.alibaba.fastjson.JSONObject;
import com.hxhq.common.ad.ADProperties;
import com.hxhq.common.ad.JdkADAuthUtil;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.security.annotation.EnableCustomConfig;
import com.hxhq.common.security.annotation.EnableRyFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

import java.util.Map;

/**
 * 系统模块
 * 
 * @author hxhq
 */
@EnableCustomConfig
@EnableRyFeignClients
@SpringBootApplication
@ComponentScan({"com.hxhq.*"})
public class HxhqIntegrationApplication
{
    public static void main(String[] args)
    {
        SpringApplication.run(HxhqIntegrationApplication.class, args);
        System.out.println("数据对接模块启动成功");


        // 测试代码示例
        ADProperties adConfig = new ADProperties();
        adConfig.setServerHost("172.21.10.1");
        adConfig.setServerPort(389);
        adConfig.setBaseDn("DC=glpcd,DC=com");
        adConfig.setUseSsl(false);
        adConfig.setConnectTimeout(5000);
        adConfig.getReadOnly().setUsername("adcon");
        adConfig.getReadOnly().setPassword("JYL@it323");
//
        JdkADAuthUtil adAuthUtil = new JdkADAuthUtil(adConfig);
//        AjaxResult elNtest01 = adAuthUtil.getUserAllAttributes("xiaokaiwei");
//        System.out.println("用户信息：" + JSONObject.toJSONString(elNtest01));
//
//
        // 测试账号存在查询（返回用户信息）
        AjaxResult existsResult = adAuthUtil.checkAccountExists("xiaokaiwei");
        System.out.println("账号存在查询结果：" + JSONObject.toJSONString(existsResult));
//
//
//        // 测试鉴权（返回用户信息）
        AjaxResult authResult = adAuthUtil.validateAccount("xiaokaiwei", "Wxk1008611");
        System.out.println("鉴权结果：" + JSONObject.toJSONString(authResult));

    }
}
