Преглед изворни кода

1.收获地址添加新字段addressDetail

qmj пре 2 недеља
родитељ
комит
30358cb810

+ 29 - 24
ruoyi-system/src/main/java/com/ruoyi/system/domain/InfoAddress.java

@@ -15,7 +15,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
 
 
 /**
 /**
  * address对象 info_address
  * address对象 info_address
- * 
+ *
  * @author ruoyi
  * @author ruoyi
  * @date 2023-05-24
  * @date 2023-05-24
  */
  */
@@ -44,9 +44,14 @@ public class InfoAddress
     private String phone;
     private String phone;
 
 
     /** 详细地址 */
     /** 详细地址 */
-    @Excel(name = "详细地址")
+    @Excel(name = "地址")
     private String address;
     private String address;
 
 
+    /**
+     * 详细地址
+     */
+    private String addressDetail;
+
     /** 经度 */
     /** 经度 */
     @Excel(name = "经度")
     @Excel(name = "经度")
     private BigDecimal longitude;
     private BigDecimal longitude;
@@ -77,102 +82,102 @@ public class InfoAddress
     @Excel(name = "距离")
     @Excel(name = "距离")
     private transient Double juli;
     private transient Double juli;
 
 
-    public void setId(Long id) 
+    public void setId(Long id)
     {
     {
         this.id = id;
         this.id = id;
     }
     }
 
 
-    public Long getId() 
+    public Long getId()
     {
     {
         return id;
         return id;
     }
     }
-    public void setUserId(Long userId) 
+    public void setUserId(Long userId)
     {
     {
         this.userId = userId;
         this.userId = userId;
     }
     }
 
 
-    public Long getUserId() 
+    public Long getUserId()
     {
     {
         return userId;
         return userId;
     }
     }
-    public void setName(String name) 
+    public void setName(String name)
     {
     {
         this.name = name;
         this.name = name;
     }
     }
 
 
-    public String getName() 
+    public String getName()
     {
     {
         return name;
         return name;
     }
     }
-    public void setPhone(String phone) 
+    public void setPhone(String phone)
     {
     {
         this.phone = phone;
         this.phone = phone;
     }
     }
 
 
-    public String getPhone() 
+    public String getPhone()
     {
     {
         return phone;
         return phone;
     }
     }
-    public void setAddress(String address) 
+    public void setAddress(String address)
     {
     {
         this.address = address;
         this.address = address;
     }
     }
 
 
-    public String getAddress() 
+    public String getAddress()
     {
     {
         return address;
         return address;
     }
     }
-    public void setLongitude(BigDecimal longitude) 
+    public void setLongitude(BigDecimal longitude)
     {
     {
         this.longitude = longitude;
         this.longitude = longitude;
     }
     }
 
 
-    public BigDecimal getLongitude() 
+    public BigDecimal getLongitude()
     {
     {
         return longitude;
         return longitude;
     }
     }
-    public void setLatitude(BigDecimal latitude) 
+    public void setLatitude(BigDecimal latitude)
     {
     {
         this.latitude = latitude;
         this.latitude = latitude;
     }
     }
 
 
-    public BigDecimal getLatitude() 
+    public BigDecimal getLatitude()
     {
     {
         return latitude;
         return latitude;
     }
     }
-    public void setCountry(String country) 
+    public void setCountry(String country)
     {
     {
         this.country = country;
         this.country = country;
     }
     }
 
 
-    public String getCountry() 
+    public String getCountry()
     {
     {
         return country;
         return country;
     }
     }
-    public void setProvince(String province) 
+    public void setProvince(String province)
     {
     {
         this.province = province;
         this.province = province;
     }
     }
 
 
-    public String getProvince() 
+    public String getProvince()
     {
     {
         return province;
         return province;
     }
     }
-    public void setCity(String city) 
+    public void setCity(String city)
     {
     {
         this.city = city;
         this.city = city;
     }
     }
 
 
-    public String getCity() 
+    public String getCity()
     {
     {
         return city;
         return city;
     }
     }
-    public void setArea(String area) 
+    public void setArea(String area)
     {
     {
         this.area = area;
         this.area = area;
     }
     }
 
 
-    public String getArea() 
+    public String getArea()
     {
     {
         return area;
         return area;
     }
     }

+ 51 - 0
ruoyi-system/src/main/java/com/ruoyi/system/utils/MobileSMS.java

@@ -1,8 +1,13 @@
 package com.ruoyi.system.utils;
 package com.ruoyi.system.utils;
+
+import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 
 
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+
 public class MobileSMS {
 public class MobileSMS {
     public void getcode(String phone,String code){
     public void getcode(String phone,String code){
         String url = "http://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_get?" +
         String url = "http://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_get?" +
@@ -17,4 +22,50 @@ public class MobileSMS {
 //        JSONObject jsonObject =  JSON.parseObject(res);
 //        JSONObject jsonObject =  JSON.parseObject(res);
         System.out.println("发送短信结果:"+res);
         System.out.println("发送短信结果:"+res);
     }
     }
+
+    /**
+     * 发送短信提醒(EngageLab)
+     * 文档:https://www.engagelab.com/zh_CN/docs/NEWSMS/REST-API/API-SMS-Sending
+     * @param phone 手机号(含国家码,如 +8613700000000)
+     * @param code  验证码/短信内容变量
+     */
+    public void getTwCode(String phone, String code)
+    {
+        // EngageLab 短信发送地址
+        String url = "https://smsapi.engagelab.com/v1/messages";
+
+        // TODO 根据实际控制台配置替换为自己的 key / secret / 模板 ID
+        String devKey = "d6kk5d4ao9hcpovohsl0";
+        String devSecret = "t7bhxkdype5p6facdna4ehja";
+        String templateId = "tw_foodie_user_register";
+
+        // Basic 认证头:Authorization: Basic base64(dev_key:dev_secret)
+        String auth = devKey + ":" + devSecret;
+        String base64Auth = java.util.Base64.getEncoder()
+                .encodeToString(auth.getBytes(StandardCharsets.UTF_8));
+
+        // 组装请求体
+        JSONObject body = new JSONObject();
+        body.put("to", Collections.singletonList(phone));
+
+        JSONObject template = new JSONObject();
+        template.put("id", templateId);
+
+        // 根据你在 EngageLab 模板中定义的变量名赋值
+        JSONObject params = new JSONObject();
+        // 假设模板中有 {{code}} 变量;如果变量名不同,请相应修改 key
+        params.put("code", code);
+
+        template.put("params", params);
+        body.put("template", template);
+
+        String res = HttpRequest.post(url)
+                .header("Authorization", "Basic " + base64Auth)
+                .header("Content-Type", "application/json")
+                .body(JSON.toJSONString(body))
+                .execute()
+                .body();
+
+        System.out.println("发送短信结果:" + res);
+    }
 }
 }

+ 5 - 1
ruoyi-system/src/main/resources/mapper/system/InfoAddressMapper.xml

@@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="name"    column="name"    />
         <result property="name"    column="name"    />
         <result property="phone"    column="phone"    />
         <result property="phone"    column="phone"    />
         <result property="address"    column="address"    />
         <result property="address"    column="address"    />
+        <result property="addressDetail"    column="address_detail"    />
         <result property="longitude"    column="longitude"    />
         <result property="longitude"    column="longitude"    />
         <result property="latitude"    column="latitude"    />
         <result property="latitude"    column="latitude"    />
         <result property="country"    column="country"    />
         <result property="country"    column="country"    />
@@ -19,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
     </resultMap>
 
 
     <sql id="selectInfoAddressVo">
     <sql id="selectInfoAddressVo">
-        select id, user_id, name, phone, address, longitude, latitude, country, province, city, area from info_address
+        select id, user_id, name, phone, address, address_detail, longitude, latitude, country, province, city, area from info_address
     </sql>
     </sql>
 
 
     <select id="selectInfoAddressList" parameterType="InfoAddress" resultMap="InfoAddressResult">
     <select id="selectInfoAddressList" parameterType="InfoAddress" resultMap="InfoAddressResult">
@@ -48,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="name != null and name != ''">name,</if>
             <if test="name != null and name != ''">name,</if>
             <if test="phone != null and phone != ''">phone,</if>
             <if test="phone != null and phone != ''">phone,</if>
             <if test="address != null and address != ''">address,</if>
             <if test="address != null and address != ''">address,</if>
+            <if test="addressDetail != null and addressDetail != ''">address_detail,</if>
             <if test="longitude != null">longitude,</if>
             <if test="longitude != null">longitude,</if>
             <if test="latitude != null">latitude,</if>
             <if test="latitude != null">latitude,</if>
             <if test="country != null">country,</if>
             <if test="country != null">country,</if>
@@ -60,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="name != null and name != ''">#{name},</if>
             <if test="name != null and name != ''">#{name},</if>
             <if test="phone != null and phone != ''">#{phone},</if>
             <if test="phone != null and phone != ''">#{phone},</if>
             <if test="address != null and address != ''">#{address},</if>
             <if test="address != null and address != ''">#{address},</if>
+            <if test="addressDetail != null and addressDetail != ''">#{addressDetail},</if>
             <if test="longitude != null">#{longitude},</if>
             <if test="longitude != null">#{longitude},</if>
             <if test="latitude != null">#{latitude},</if>
             <if test="latitude != null">#{latitude},</if>
             <if test="country != null">#{country},</if>
             <if test="country != null">#{country},</if>
@@ -76,6 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="name != null and name != ''">name = #{name},</if>
             <if test="name != null and name != ''">name = #{name},</if>
             <if test="phone != null and phone != ''">phone = #{phone},</if>
             <if test="phone != null and phone != ''">phone = #{phone},</if>
             <if test="address != null and address != ''">address = #{address},</if>
             <if test="address != null and address != ''">address = #{address},</if>
+            <if test="addressDetail != null and addressDetail != ''">address_detail = #{addressDetail},</if>
             <if test="longitude != null">longitude = #{longitude},</if>
             <if test="longitude != null">longitude = #{longitude},</if>
             <if test="latitude != null">latitude = #{latitude},</if>
             <if test="latitude != null">latitude = #{latitude},</if>
             <if test="country != null">country = #{country},</if>
             <if test="country != null">country = #{country},</if>