package com.malk.tuosi.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.malk.server.common.McR;
import com.malk.tuosi.service.TBService;
import com.malk.tuosi.service.impl.TbServiceImpl;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/TBConstructionLog")
public class TBController {
    @Autowired
    private TBService tbService;

    /*TODO:TB获取应用授权token*/
    @SneakyThrows
    @PostMapping("/GetAppToken")
    McR AppAccessToken() throws JsonProcessingException {
        log.info("---------获取到token---------");
        return tbService.AppAccessToken();
    }

    /*TODO：钉钉获取应用token（欧诺）*/
    @PostMapping("/GetDingToken")
    McR AccessToken() throws JsonProcessingException{
        log.info("---------获取到dingtoken-------");
        return tbService.Accesstoken();
    }

    /*TODO:钉钉获取应用token(欧诺信)*/
    @PostMapping("/GetOuNuoXinAccessToken")
    McR OuNuoXinAccessToken() throws JsonProcessingException{
        log.info("---------获取到dingtoken-------");
        return tbService.OuNuoXinAccessToken();
    }

    /*TODO：TB事件订阅接口*/
    @PostMapping("/tbTaskUpdate")
    McR tbTaskUpdate(@RequestBody Map body) throws JsonProcessingException{
        return McR.success(tbService.tbTaskUpdate(body));
    }

    /*TODO：钉盘文件上传*/
    @PostMapping("/uploadKnowledge")
    McR uploadKnowledge(@RequestParam  String pathName, @RequestParam String fileName,@RequestParam String fileType) throws JsonProcessingException{
        return McR.success(tbService.uploadKnowledge(pathName,fileName,fileType));
    }

    /*TODO：版线组位置附件上传CRM*/
    @PostMapping("/tbCallbackCRM")
    McR tbCallbackCRM(@RequestBody Map body) throws JsonProcessingException{
        return McR.success(tbService.tbCallbackCRM(body));
    }

    /*TODO：OA回传TB*/
    @PostMapping("/oaCallbackTB")
    McR oaCallbackTB(@RequestBody Map body) throws  JsonProcessingException{
        return McR.success(tbService.oaCallbackTB(body));
    }

    /*TODO：Teambition userId 查询钉钉 userId*/

    @PostMapping("/TBtoDinguserId")
    McR TBtoDinguserId(@RequestParam List list) throws JsonProcessingException{
        return McR.success(tbService.TBtoDinguserId(list));
    }



}
