GithubHelp home page GithubHelp logo

flanliulf / dingtalk-robot-spring-boot-starter Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 24 KB

dingtalk-robot-spring-boot-starter 项目是一个接入钉钉自定义钉机器人接口,用于钉钉群机器人推送消息的 Spring Boot Starter 项目。

License: Apache License 2.0

Java 100.00%

dingtalk-robot-spring-boot-starter's Introduction

简介

dingtalk-robot-spring-boot-starter 项目是一个接入钉钉自定义钉机器人接口,用于钉钉群机器人推送消息的 Spring Boot Starter 项目。

本项目参考了钉钉官方的 Java SDK,对一些常用的场景进行封装,对于常见的基于 Spring Boot 体系的 Java 项目,提供了更方便快捷的引入和使用方式。

本项目可以广泛适用于短信发送测试,预警消息推送等业务场景。

依赖组件

组件 说明
hutool-core 核心工具类,引入用于Bean操作、日期、各种Util等
hutool-http http 请求工具类,基于HttpUrlConnection的Http客户端封装
fastjson JSON 工具类

安装

Maven

在项目的 pom.xml 的 dependencies 中加入以下内容:

<dependency>
  <groupId>com.fancyliu</groupId>
  <artifactId>dingtalk-robot-spring-boot-starter</artifactId>
  <version>1.0.0</version>
</dependency>

快速入门

下面以发送简单的文本消息内容为例,来展示如何使用 dingtalk-robot-spring-boot-starter ,通常只需要以下三步:

1. 引入发送服务对象

在需要发送消息的地方注入 RobotSendService 类;

    @Autowired
    private RobotSendService robotSendService;

2. 封装内容实体对象

如果是 http 调用,请参考以下格式封装请求 body:

{
    "content": "验证码测试文本内容 xxxx @18612341234",
    "atMobiles": [
        "18612341234"
    ],
    "isAtAll": false
}

3. 调用发送方法

调用 robotSendService 的 sendText(TextEntity textEntity)方法,即可发送。

示例代码

@RestController
@RequestMapping(value = "/dingtalk/robot")
public class DingtalkController {

    @Autowired
    private RobotSendService robotSendService;

    /**
     * <p>发送简单文本内容消息</p>
     *
     * @param textEntity 消息文本封装对象
     * @return
     */
    @PostMapping(value = "/send/text")
    public String sendTextMessage(@RequestBody TextEntity textEntity) {
        return robotSendService.sendText(textEntity);
    }
}

image-20200222200920456

分支说明

注意事项

参考文档

dingtalk-robot-spring-boot-starter's People

Contributors

flanliulf avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

anglabace

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.