package com.cm.common.dingding.controller.api;

import com.alibaba.fastjson.JSONObject;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.dingding.service.IDingDingAppDepartmentService;
import com.cm.common.dingding.service.IDingDingMessageService;
import com.cm.common.result.SuccessResult;
import com.taobao.api.ApiException;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: DemoController
 * @Description:
 * @Author: WangGeng
 * @Date: 2020/9/24 16:38
 * @Version: 1.0
 **/
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "钉钉消息接口")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/demomessage")
public class DemoController {

    @Autowired
    private IDingDingMessageService dingDingMessageService;
    @Autowired
    private IDingDingAppDepartmentService dingDingAppDepartmentService;

    @GetMapping("sendmessage/{phone}")
    public SuccessResult sendMessage(@PathVariable("phone") String phone) {
        return dingDingMessageService.send(phone, "测试");
    }

    @GetMapping("list")
    public JSONObject list() throws ApiException {
        return dingDingAppDepartmentService.list();
    }

}
