package com.muzhi.dingtalk.test.controller;

import com.alibaba.fastjson.JSONObject;
import com.muzhi.dingtalk.test.entity.vo.EmployeeFangDeToChuanYunDataVo;
import com.muzhi.dingtalk.test.entity.vo.EmployeeFangDeToChuanYunVo;
import com.muzhi.dingtalk.test.service.ChuanYunTongbuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "同步数据至NC接口")
@RestController
@RequestMapping("/chuanyuntongbuservice/chuanyuntongbu")
@CrossOrigin//解决跨域问题
public class ChuanYunTongbuController {

    @Autowired
    private ChuanYunTongbuService chuanYunTongbuService;

    //查询钉钉接口中所有的房德花名册数据
    @GetMapping("getFangDeHuamingceAll")
    public String getFangDeHuamingceAll(){

        String fangDeHuamingceAll = chuanYunTongbuService.getFangDeHuamingceAll();

        return fangDeHuamingceAll;
    }

    @ApiOperation(value = "同步房德钉钉花名册指定数据至氚云接口")
    @GetMapping("getFangDeHuamingceToCY")
//    @Scheduled(cron = "0 1 15 * * ?")//每天下午15：01触发（也就是下午3点触发）
//    @Scheduled(cron = "0 0 0 * * ?")//每天00：00触发（也就是凌晨0点整触发）
    public EmployeeFangDeToChuanYunDataVo getFangDeHuamingceToCY(){

        //将房德钉钉花名册数据先处理成指定的json格式数据
        EmployeeFangDeToChuanYunDataVo<EmployeeFangDeToChuanYunVo> fangDeHuamingceToCY = chuanYunTongbuService.getFangDeHuamingceToCY();

        return fangDeHuamingceToCY;
    }
}
