• 发送钉钉、邮件、手机信息


    其中下列部分用到了Hutool中的工具,可先导入Hutool依赖

     <dependency>
          <groupId>cn.hutool</groupId>
          <artifactId>hutool-all</artifactId>
          <version>5.8.16</version>
     </dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5

    钉钉

     public void sendDingDing(PoMaster poMaster){
            String url="钉钉机器人的opai";
            JSONObject js = new JSONObject();
            js.set("msgtype","markdown");
            js.set("markdown",new JSONObject()
                    .set("title"," 益达律师所邀请您审核采购单")
                    .set("text","益达律师所邀您查看编号:"+poMaster.getId()+"的订单 ![screenshot](https://pic.3gbizhi.com/uploads/20231129/0750e85fa5fd97e19dfb879770d7f7db.jpg)\n"));
    		//js.set("at",new JSONObject().set("atMobiles",new JSONArray().set("tel"))); 按照手机号发送
            js.set("at",new JSONObject().set("isAtAll",true));
            String s = JSONUtil.toJsonStr(js);
            HttpRequest.post(url).body(s).execute().body();
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    邮件

     public Integer sendEmail(String email) {
            MailAccount account = new MailAccount();
            account.setHost("smtp.aliyun.com");
            account.setPort(25);
            account.setAuth(true);
            account.setFrom("your Email");
            account.setUser("your Email");
            account.setPass("your Password");
            int code = RandomUtil.randomInt(1000, 10000);
            String url="https://baike.baidu.com/item/%E5%A4%A9%E4%B8%8A%E4%BA%BA%E9%97%B4/11074119";
            String content = "天上人间提醒您,您的验证码为:"+code+"请勿给他人观看及使用🥰🥰";
            TelMap.put(email,code);
            MailUtil.send(account, CollUtil.newArrayList(email), "天上人间", content, false);
            return 0;
        }
    
    
    
    //发送带样式Email
    ublic void sendEmail(PoMaster poMaster){
            MailAccount account = new MailAccount();
            account.setHost("smtp.aliyun.com");
            account.setPort(25);
            account.setAuth(true);
            account.setFrom("your Email");
            account.setUser("your Email");
            account.setPass("your Password");
            StringBuilder body = new StringBuilder();
            body.append(StrUtil.format("

    采购单:{},总金额:{}, 需要您的审核🥰🥰

    "
    , poMaster.getId(), poMaster.getTotalPrice())); body.append(" "); body.append(" "); body.append(" "); body.append(" "); body.append(" "); body.append(" "); body.append(" "); poMaster.getItems().forEach(item ->{ body.append(" "); body.append(" "); body.append(" "); body.append(" "); body.append(" "); body.append(" ");}); body.append("
    "); body.append("商品名称"); body.append(" "); body.append("采购数量"); body.append(" "); body.append("采购单价"); body.append(" "); body.append(" 商品金额"); body.append("
    "); body.append(StrUtil.format("{}", item.getId(), item.getProductName())); body.append(" "); body.append(item.getQty()); body.append(" "); body.append("¥"+item.getPrice()); body.append(" "); body.append("¥"+item.getPrice().multiply(new BigDecimal(item.getQty()))); body.append("
    "
    ); MailUtil.send(account,"需要发送的Email","天上人间提醒您请对采购单审核-"+ poMaster.getId(),body.toString(),true); }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64

    手机信息

    public Integer sendTel(String tel) {
            //发送信息调用地址
            String url="https://dfsns.market.alicloudapi.com/data/send_sms";
            //请求放法
            String method = "POST";
            //我的appcode号
            String appcode = "eb666bd7a6474c37aee78f8fe886a763";
            int code = RandomUtil.randomInt(1000, 10000);
            TelMap.put(tel,code);
            String result = HttpRequest.post(url)
                    .header("Authorization", "APPCODE "+appcode)//头信息,多个头信息多次调用此方法即可
                    .body("content=code:"+code+"&template_id=TPL_0000&phone_number="+tel)
                    .execute().body();
            JSONObject entries = JSONUtil.parseObj(result);
            if(!entries.get("status").equals("OK")){
                throw new BizException(401,"验证码发送失败");
            }
            return 0;
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
  • 相关阅读:
    Linux的难题,终于有解了
    基于SpringBoot的校园志愿者管理系统
    架构真题2017(五十三)
    Golang | Leetcode Golang题解之第326题3的幂
    Linux编程知识之GLIB的GOption接口函数
    第4章——处理器体系结构
    An Empirical Study of GPT-3 for Few-Shot Knowledge-Based VQA
    Flink部署——Debugging(开发实用,建议收藏)
    内核实战教程第二期|带你揭开数据库存储结构的神秘面纱
    数据库的三范式及BC范式
  • 原文地址:https://blog.csdn.net/qq_52776163/article/details/137838005