package com.zfire.mall.manager.controller.dingding;

import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.*;
import com.dingtalk.api.response.*;
import com.taobao.api.ApiException;
import com.zfire.mall.manager.annotation.ApiNotAuth;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.dingding.DingDingLogic;
import com.zfire.mall.manager.plus.entity.DingdingUser;
import com.zfire.mall.manager.plus.service.DingdingUserService;
import com.zfire.mall.manager.utils.DingDingOAUtils;
import com.zfire.mall.manager.utils.RedisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
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 javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author change
 * @description 企微回调通知接口
 * @date 2022/05/18 14:31
 **/
@Api(tags = "钉钉OA审批")
@Slf4j
@RestController
@RequestMapping("/ALi/dingDing")
public class DingDingController {


    @Autowired
    DingDingLogic dingDingLogic;


    @Autowired
    RedisUtil redisUtil;

    @ApiModelProperty("获得token")
    @PostMapping(value = "/getToken")
    @ApiNotAuth
    public ResponseHelper<String> recive() throws ApiException {
        String ding = dingDingLogic.getAccessToken();
        return ResponseHelper.success(ding);
    }


    @PostMapping("/updateUser")
    @ApiModelProperty("更新用户,和部门")
    @ApiNotAuth
    public ResponseHelper expressCallback(HttpServletRequest request) throws Exception {

        dingDingLogic.saveUserInfo();
        return ResponseHelper.success();
    }



}
