package com.shulead.datasync.manager;

import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiV2DepartmentGetRequest;
import com.dingtalk.api.response.OapiV2DepartmentGetResponse;
import com.shulead.datasync.DatasyncApplication;
import com.shulead.datasync.entity.UfHzqy;
import com.taobao.api.ApiException;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * @Classname UfHzqyManagerTest
 * @Description TODO
 * @Version 1.0.0
 * @Date 2024/5/13 17:16
 * @Created by liuxiangshun
 */
@SpringBootTest(classes = DatasyncApplication.class)
public class UfHzqyManagerTest {
    @Resource
    private UfHzqyManager ufHzqyManager;

    @Resource
    private YiDaManager yiDaManager;

    @Test
    public void test() throws ApiException {
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/get");
        OapiV2DepartmentGetRequest req = new OapiV2DepartmentGetRequest();
        req.setDeptId(105L);
        req.setLanguage("zh_CN");
        OapiV2DepartmentGetResponse rsp = client.execute(req, yiDaManager.getAccessToken());
        System.out.println(rsp.getBody());


        List<UfHzqy> ufHzqies = ufHzqyManager.findAll();
        System.out.println(ufHzqies);
    }
}
