package com.malk.chuizi.controller;

import com.malk.chuizi.service.ChuiZiService;
import com.malk.server.common.McR;
import com.malk.service.dingtalk.DDClient;
import com.malk.service.dingtalk.DDClient_Workflow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class ChuiziController {

    @Autowired
    ChuiZiService chuiZiService;

    @Autowired
    private DDClient ddClient;

    @Autowired
    private DDClient_Workflow ddClient_workflow;

    /// dingtalk
    final String APP_EKY = "ding9seotugcsfjlgy8h";
    final String APP_SECRET = "4k6hoCDUwwpUG5WXijfWcnzIm97j_zGquJqXJgrkBcyp2vo7ceV6dO-nSDUUDMhE";
    @GetMapping("/test")
    public McR test(){
        return McR.success();
    }

    //新增其他应付单
    @PostMapping("/saveOtherMeet")
    public McR saveOtherMeet(@RequestBody Map data) {
        String token = ddClient.getAccessToken(APP_EKY, APP_SECRET);
        Map processData = ddClient_workflow.getProcessInstanceId(token, data.get("id").toString());
        return chuiZiService.saveOtherMeet(processData);
    }


}
