package com.muzhi.dingtalk.test.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiAttendanceVacationQuotaInitRequest;
import com.dingtalk.api.request.OapiAttendanceVacationQuotaUpdateRequest;
import com.dingtalk.api.request.OapiProcessinstanceGetRequest;
import com.dingtalk.api.response.OapiAttendanceVacationQuotaUpdateResponse;
import com.dingtalk.api.response.OapiProcessinstanceGetResponse;
import com.muzhi.dingtalk.test.service.DingAccessTokenService;
import com.muzhi.dingtalk.test.service.DingdingLianJieQiService;
import com.taobao.api.ApiException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Api(description = "同步数据至数据库")
@RestController
@RequestMapping("/lianjieqiservice/OA")
@CrossOrigin//解决跨域问题
public class DingdingLianJieQiController {


    @Autowired
    private DingdingLianJieQiService dingdingLianJieQiService;


    //抓取钉钉OA审批中通过连接器传输过来的创建审批单的时间
    @ApiOperation(value = "抓取钉钉OA审批中通过连接器传输过来的创建审批单的时间")
    @GetMapping("getOATime")
    public String getOATime(){

        String oaTime = dingdingLianJieQiService.getOATime();
        System.out.println(oaTime);

        return oaTime;
    }

    //抓取钉钉OA审批中通过连接器传输过来的控件数据值，并根据审批单的加班时长进行计算并追加到假期余额中
    @ApiOperation(value = "抓取钉钉OA审批中通过连接器传输过来的控件数据值，并根据审批单的加班时长进行计算并追加到假期余额中")
    @GetMapping("getOA")
    public String getOA(String processid){

        String oa = dingdingLianJieQiService.getOA(processid);

        return oa;
    }

    //抓取钉钉OA审批中通过连接器传输过来的控件数据值，并根据实际打卡时间进行计算加班时长并追加到假期余额中
    @ApiOperation(value = "抓取钉钉OA审批中通过连接器传输过来的控件数据值，并根据实际打卡时间进行计算加班时长并追加到假期余额中")
    @GetMapping("getOA2")
    public String getOA2(String processid){

        String oa2 = dingdingLianJieQiService.getOA2(processid);

        return oa2;
    }

}