<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ### egg 發送短信邏輯 service ``` 'use strict'; const Service = require('egg').Service; class UserService extends Service { /** * 發送驗證碼 */ async sendCode() { //1. 獲取用戶手機號 const { phone } = this.ctx.request.body; //2. 緩存中查詢該手機號是否存在 const sendCodePhone = await this.service.cache.get(`sendCode_${phone}`); if (sendCodePhone) this.ctx.errorHandle('您操作的太快了,驗證碼還未過期!', {}, 30001); //3. 生成隨機四位驗證碼 const randomCode = this.ctx.random(); // 調試環境 不請求阿里服務器 if (!this.config.aliSMS.isopen) { await this._devCode(phone, randomCode); } //4. 請求阿里云API發送驗證碼 const ret = await this.service.alisms.sendSMS(phone, randomCode); if (ret.Code === "OK") { // 5.發送成功寫入redis緩存 60 秒過期 this.service.cache.set(`sendCode_${phone}`, randomCode, this.config.aliSMS.expire); // 6.寫入消息隊列 this.ctx.succHandle('發送驗證碼成功!'); } } // 模擬發送短信驗證碼 async _devCode(phone, randomCode) { this.service.cache.set(`sendCode_${phone}`, randomCode, this.config.aliSMS.expire); this.ctx.succHandle('請求驗證碼成功!', { randomCode }, 30002); } } module.exports = UserService; ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看