package com.malk.mcli.controller;

import com.alibaba.fastjson.JSON;
import com.malk.server.aliwork.YDConf;
import com.malk.server.aliwork.YDParam;
import com.malk.server.common.McR;
import com.malk.service.aliwork.YDClient;
import com.malk.service.dingtalk.DDClient;
import com.malk.service.dingtalk.DDClient_Contacts;
import com.malk.utils.UtilMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

/**
 * 错误抛出与拦截详见CatchException
 */
@Slf4j
@RestController
@RequestMapping("/t")
public class TControl {

    @Autowired
    private YDClient ydClient;

    @PostMapping("test")
    McR test() {

        ydClient.operateData(YDParam.builder()
                .formUuid("FORM-33666CB1C60F2AYREV95GC73TI3R3U5TU1NNLD")
                .formDataJson(JSON.toJSONString(UtilMap.map("employeeField_lnn1v0s6", Arrays.asList("681140625426103999"))))
                .processCode("TPROC--33666CB1C60F2AYREV95GC73TI3R3V5TU1NNLE")
                .build(), YDConf.FORM_OPERATION.start);
        return McR.success();
    }

    @Autowired
    private DDClient ddClient;

    @Autowired
    private DDClient_Contacts ddClient_contacts;

    @PostMapping("test11")
    McR test11() {

        ddClient_contacts.getUserInfoById(ddClient.getAccessToken(), "095515432139833944");
        return McR.success();
    }
}
