diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java index aa1eedf24..1f162a8ef 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java @@ -3,12 +3,10 @@ package com.stdiet.web.controller.custom; import com.stdiet.common.core.controller.BaseController; import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.utils.DateUtils; +import com.stdiet.common.utils.StringUtils; import com.stdiet.custom.domain.SysOrderPause; import com.stdiet.custom.domain.SysWxAdLog; -import com.stdiet.custom.service.ISysOrderPauseService; -import com.stdiet.custom.service.ISysRecipesService; -import com.stdiet.custom.service.ISysWapServices; -import com.stdiet.custom.service.ISysWxSaleAccountService; +import com.stdiet.custom.service.*; import com.stdiet.custom.utils.HttpRequestUtils; import com.stdiet.system.service.ISysDictTypeService; import org.springframework.beans.factory.annotation.Autowired; @@ -37,6 +35,9 @@ public class SysWapController extends BaseController { @Autowired ISysWxSaleAccountService iSysWxSaleAccountService; + @Autowired + ISysSmsConfirmServie iSysSmsConfirmServie; + /** * 客户食谱详情 * @@ -139,4 +140,39 @@ public class SysWapController extends BaseController { return toAjax(iSysWxSaleAccountService.logWxAd(sysWxAdLog)); } + @GetMapping(value = "/getCode") + public AjaxResult getCode(@RequestParam String phone) { + + if (!StringUtils.isMobileNO(phone)) { + return AjaxResult.error(50001, "非法手机号"); + } + + int code = iSysSmsConfirmServie.sendSmsCode(phone); + if (code == 1) { + return AjaxResult.error(50001, "非法手机号"); + } else if (code == 0) { + return AjaxResult.success(); + } else { + return AjaxResult.error(); + } + + } + + @GetMapping(value = "/checkCode") + public AjaxResult checkCode(@RequestParam String phone, @RequestParam String code) { + if (StringUtils.isEmpty(code)) { + return AjaxResult.error(50002, "验证码不能为空"); + } + int checkCode = iSysSmsConfirmServie.checkSmsCode(phone, code); + if (checkCode == 0) { + return AjaxResult.success(); + } else if (checkCode == 1) { + return AjaxResult.error(50003, "验证码失效"); + } else if (checkCode == 2) { + return AjaxResult.error(50004, "验证码错误"); + } else { + return AjaxResult.error(); + } + } + } diff --git a/stdiet-common/src/main/java/com/stdiet/common/utils/StringUtils.java b/stdiet-common/src/main/java/com/stdiet/common/utils/StringUtils.java index c7e999dbe..7781903b9 100644 --- a/stdiet-common/src/main/java/com/stdiet/common/utils/StringUtils.java +++ b/stdiet-common/src/main/java/com/stdiet/common/utils/StringUtils.java @@ -1,191 +1,174 @@ package com.stdiet.common.utils; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; import com.stdiet.common.core.text.StrFormatter; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * 字符串工具类 - * + * * @author ruoyi */ -public class StringUtils extends org.apache.commons.lang3.StringUtils -{ - /** 空字符串 */ +public class StringUtils extends org.apache.commons.lang3.StringUtils { + /** + * 空字符串 + */ private static final String NULLSTR = ""; - /** 下划线 */ + /** + * 下划线 + */ private static final char SEPARATOR = '_'; /** * 获取参数不为空值 - * + * * @param value defaultValue 要判断的value * @return value 返回值 */ - public static T nvl(T value, T defaultValue) - { + public static T nvl(T value, T defaultValue) { return value != null ? value : defaultValue; } /** * * 判断一个Collection是否为空, 包含List,Set,Queue - * + * * @param coll 要判断的Collection * @return true:为空 false:非空 */ - public static boolean isEmpty(Collection coll) - { + public static boolean isEmpty(Collection coll) { return isNull(coll) || coll.isEmpty(); } /** * * 判断一个Collection是否非空,包含List,Set,Queue - * + * * @param coll 要判断的Collection * @return true:非空 false:空 */ - public static boolean isNotEmpty(Collection coll) - { + public static boolean isNotEmpty(Collection coll) { return !isEmpty(coll); } /** * * 判断一个对象数组是否为空 - * + * * @param objects 要判断的对象数组 - ** @return true:为空 false:非空 + * * @return true:为空 false:非空 */ - public static boolean isEmpty(Object[] objects) - { + public static boolean isEmpty(Object[] objects) { return isNull(objects) || (objects.length == 0); } /** * * 判断一个对象数组是否非空 - * + * * @param objects 要判断的对象数组 * @return true:非空 false:空 */ - public static boolean isNotEmpty(Object[] objects) - { + public static boolean isNotEmpty(Object[] objects) { return !isEmpty(objects); } /** * * 判断一个Map是否为空 - * + * * @param map 要判断的Map * @return true:为空 false:非空 */ - public static boolean isEmpty(Map map) - { + public static boolean isEmpty(Map map) { return isNull(map) || map.isEmpty(); } /** * * 判断一个Map是否为空 - * + * * @param map 要判断的Map * @return true:非空 false:空 */ - public static boolean isNotEmpty(Map map) - { + public static boolean isNotEmpty(Map map) { return !isEmpty(map); } /** * * 判断一个字符串是否为空串 - * + * * @param str String * @return true:为空 false:非空 */ - public static boolean isEmpty(String str) - { + public static boolean isEmpty(String str) { return isNull(str) || NULLSTR.equals(str.trim()); } /** * * 判断一个字符串是否为非空串 - * + * * @param str String * @return true:非空串 false:空串 */ - public static boolean isNotEmpty(String str) - { + public static boolean isNotEmpty(String str) { return !isEmpty(str); } /** * * 判断一个对象是否为空 - * + * * @param object Object * @return true:为空 false:非空 */ - public static boolean isNull(Object object) - { + public static boolean isNull(Object object) { return object == null; } /** * * 判断一个对象是否非空 - * + * * @param object Object * @return true:非空 false:空 */ - public static boolean isNotNull(Object object) - { + public static boolean isNotNull(Object object) { return !isNull(object); } /** * * 判断一个对象是否是数组类型(Java基本型别的数组) - * + * * @param object 对象 * @return true:是数组 false:不是数组 */ - public static boolean isArray(Object object) - { + public static boolean isArray(Object object) { return isNotNull(object) && object.getClass().isArray(); } /** * 去空格 */ - public static String trim(String str) - { + public static String trim(String str) { return (str == null ? "" : str.trim()); } /** * 截取字符串 - * - * @param str 字符串 + * + * @param str 字符串 * @param start 开始 * @return 结果 */ - public static String substring(final String str, int start) - { - if (str == null) - { + public static String substring(final String str, int start) { + if (str == null) { return NULLSTR; } - if (start < 0) - { + if (start < 0) { start = str.length() + start; } - if (start < 0) - { + if (start < 0) { start = 0; } - if (start > str.length()) - { + if (start > str.length()) { return NULLSTR; } @@ -194,44 +177,36 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 截取字符串 - * - * @param str 字符串 + * + * @param str 字符串 * @param start 开始 - * @param end 结束 + * @param end 结束 * @return 结果 */ - public static String substring(final String str, int start, int end) - { - if (str == null) - { + public static String substring(final String str, int start, int end) { + if (str == null) { return NULLSTR; } - if (end < 0) - { + if (end < 0) { end = str.length() + end; } - if (start < 0) - { + if (start < 0) { start = str.length() + start; } - if (end > str.length()) - { + if (end > str.length()) { end = str.length(); } - if (start > end) - { + if (start > end) { return NULLSTR; } - if (start < 0) - { + if (start < 0) { start = 0; } - if (end < 0) - { + if (end < 0) { end = 0; } @@ -246,15 +221,13 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
- * + * * @param template 文本模板,被替换的部分用 {} 表示 - * @param params 参数值 + * @param params 参数值 * @return 格式化后的文本 */ - public static String format(String template, Object... params) - { - if (isEmpty(params) || isEmpty(template)) - { + public static String format(String template, Object... params) { + if (isEmpty(params) || isEmpty(template)) { return template; } return StrFormatter.format(template, params); @@ -262,47 +235,40 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 字符串转set - * + * * @param str 字符串 * @param sep 分隔符 * @return set集合 */ - public static final Set str2Set(String str, String sep) - { + public static final Set str2Set(String str, String sep) { return new HashSet(str2List(str, sep, true, false)); } /** * 字符串转list - * - * @param str 字符串 - * @param sep 分隔符 + * + * @param str 字符串 + * @param sep 分隔符 * @param filterBlank 过滤纯空白 - * @param trim 去掉首尾空白 + * @param trim 去掉首尾空白 * @return list集合 */ - public static final List str2List(String str, String sep, boolean filterBlank, boolean trim) - { + public static final List str2List(String str, String sep, boolean filterBlank, boolean trim) { List list = new ArrayList(); - if (StringUtils.isEmpty(str)) - { + if (StringUtils.isEmpty(str)) { return list; } // 过滤空白字符串 - if (filterBlank && StringUtils.isBlank(str)) - { + if (filterBlank && StringUtils.isBlank(str)) { return list; } String[] split = str.split(sep); - for (String string : split) - { - if (filterBlank && StringUtils.isBlank(string)) - { + for (String string : split) { + if (filterBlank && StringUtils.isBlank(string)) { continue; } - if (trim) - { + if (trim) { string = string.trim(); } list.add(string); @@ -314,10 +280,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 下划线转驼峰命名 */ - public static String toUnderScoreCase(String str) - { - if (str == null) - { + public static String toUnderScoreCase(String str) { + if (str == null) { return null; } StringBuilder sb = new StringBuilder(); @@ -327,31 +291,23 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils boolean curreCharIsUpperCase = true; // 下一字符是否大写 boolean nexteCharIsUpperCase = true; - for (int i = 0; i < str.length(); i++) - { + for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); - if (i > 0) - { + if (i > 0) { preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); - } - else - { + } else { preCharIsUpperCase = false; } curreCharIsUpperCase = Character.isUpperCase(c); - if (i < (str.length() - 1)) - { + if (i < (str.length() - 1)) { nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); } - if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) - { + if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) { sb.append(SEPARATOR); - } - else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) - { + } else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) { sb.append(SEPARATOR); } sb.append(Character.toLowerCase(c)); @@ -362,19 +318,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 是否包含字符串 - * - * @param str 验证字符串 + * + * @param str 验证字符串 * @param strs 字符串组 * @return 包含返回true */ - public static boolean inStringIgnoreCase(String str, String... strs) - { - if (str != null && strs != null) - { - for (String s : strs) - { - if (str.equalsIgnoreCase(trim(s))) - { + public static boolean inStringIgnoreCase(String str, String... strs) { + if (str != null && strs != null) { + for (String s : strs) { + if (str.equalsIgnoreCase(trim(s))) { return true; } } @@ -384,31 +336,25 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld - * + * * @param name 转换前的下划线大写方式命名的字符串 * @return 转换后的驼峰式命名的字符串 */ - public static String convertToCamelCase(String name) - { + public static String convertToCamelCase(String name) { StringBuilder result = new StringBuilder(); // 快速检查 - if (name == null || name.isEmpty()) - { + if (name == null || name.isEmpty()) { // 没必要转换 return ""; - } - else if (!name.contains("_")) - { + } else if (!name.contains("_")) { // 不含下划线,仅将首字母大写 return name.substring(0, 1).toUpperCase() + name.substring(1); } // 用下划线将原始字符串分割 String[] camels = name.split("_"); - for (String camel : camels) - { + for (String camel : camels) { // 跳过原始字符串中开头、结尾的下换线或双重下划线 - if (camel.isEmpty()) - { + if (camel.isEmpty()) { continue; } // 首字母大写 @@ -421,30 +367,22 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils /** * 驼峰式命名法 例如:user_name->userName */ - public static String toCamelCase(String s) - { - if (s == null) - { + public static String toCamelCase(String s) { + if (s == null) { return null; } s = s.toLowerCase(); StringBuilder sb = new StringBuilder(s.length()); boolean upperCase = false; - for (int i = 0; i < s.length(); i++) - { + for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); - if (c == SEPARATOR) - { + if (c == SEPARATOR) { upperCase = true; - } - else if (upperCase) - { + } else if (upperCase) { sb.append(Character.toUpperCase(c)); upperCase = false; - } - else - { + } else { sb.append(c); } } @@ -452,15 +390,21 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } @SuppressWarnings("unchecked") - public static T cast(Object obj) - { + public static T cast(Object obj) { return (T) obj; } /** * 手机号隐式处理 - * */ - public static String hiddenPhoneNumber(String phoneNumber){ + */ + public static String hiddenPhoneNumber(String phoneNumber) { return phoneNumber.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"); } + + public static boolean isMobileNO(String phone) { + String rule = "((\\+86|0086)?\\s*)((134[0-8]\\d{7})|(((13([0-3]|[5-9]))|(14[5-9])|15([0-3]|[5-9])|(16(2|[5-7]))|17([0-3]|[5-8])|18[0-9]|19(1|[8-9]))\\d{8})|(14(0|1|4)0\\d{7})|(1740([0-5]|[6-9]|[10-12])\\d{7}))"; + Pattern p = Pattern.compile(rule); + Matcher m = p.matcher(phone); + return m.matches(); + } } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRedisService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRedisService.java new file mode 100644 index 000000000..76c85e0b0 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRedisService.java @@ -0,0 +1,13 @@ +package com.stdiet.custom.service; + +public interface ISysRedisService { + void set(String key, String value); + + String get(String key); + + Boolean expire(String key, long expire); + + void remove(String key); + + Long increment(String key, long delta); +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysSmsConfirmServie.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysSmsConfirmServie.java new file mode 100644 index 000000000..632fb7b1c --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysSmsConfirmServie.java @@ -0,0 +1,9 @@ +package com.stdiet.custom.service; + +public interface ISysSmsConfirmServie { + + public Integer sendSmsCode(String phone); + + public Integer checkSmsCode(String phone, String code); + +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRedisServiceImp.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRedisServiceImp.java new file mode 100644 index 000000000..cfaf42643 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRedisServiceImp.java @@ -0,0 +1,40 @@ +package com.stdiet.custom.service.impl; + +import com.stdiet.custom.service.ISysRedisService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.concurrent.TimeUnit; + +@Service +public class SysRedisServiceImp implements ISysRedisService { + + @Autowired + private StringRedisTemplate stringRedisTemplate; + + @Override + public void set(String key, String value) { + stringRedisTemplate.opsForValue().set(key, value); + } + + @Override + public String get(String key) { + return stringRedisTemplate.opsForValue().get(key); + } + + @Override + public Boolean expire(String key, long expire) { + return stringRedisTemplate.expire(key, expire, TimeUnit.SECONDS); + } + + @Override + public void remove(String key) { + stringRedisTemplate.delete(key); + } + + @Override + public Long increment(String key, long delta) { + return stringRedisTemplate.opsForValue().increment(key, delta); + } +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysSmsConfirmServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysSmsConfirmServiceImpl.java new file mode 100644 index 000000000..824128f45 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysSmsConfirmServiceImpl.java @@ -0,0 +1,87 @@ +package com.stdiet.custom.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; +import com.aliyuncs.exceptions.ClientException; +import com.stdiet.common.utils.DateUtils; +import com.stdiet.common.utils.StringUtils; +import com.stdiet.custom.domain.wechat.WxSubscribePostLog; +import com.stdiet.custom.service.ISysRedisService; +import com.stdiet.custom.service.ISysSmsConfirmServie; +import com.stdiet.custom.service.IWxSubscribePostLogService; +import com.stdiet.custom.utils.SmsUtils; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SysSmsConfirmServiceImpl implements ISysSmsConfirmServie { + + private static long CODE_EXPIRE_SECONDS = 600; //设置验证码过期时间为600秒 + + @Autowired + ISysRedisService redisService; + @Autowired + IWxSubscribePostLogService wxSubscribePostLogService; + + + @Override + public Integer sendSmsCode(String phone) { + int reCode = -1; + try { + String code = RandomStringUtils.randomNumeric(6); + JSONObject paramObj = new JSONObject(); + paramObj.put("code", code); + SendSmsResponse response = SmsUtils.sendSms(phone, paramObj.toJSONString(), SmsUtils.SMS_217025172); + if (response.getCode().equals("OK")) { + // 发送成功 + redisService.remove(phone); + redisService.set(phone, code); + redisService.expire(phone, CODE_EXPIRE_SECONDS); + reCode = 0; + } else if (response.getCode().equals("isv.MOBILE_NUMBER_ILLEGAL")) { + // 非法手机号 + reCode = 1; + } + + WxSubscribePostLog postLog = new WxSubscribePostLog(); + postLog.setPhone(phone); + JSONObject resultObj = new JSONObject(); + resultObj.put("requestId", response.getRequestId()); + resultObj.put("bizId", response.getBizId()); + resultObj.put("code", response.getCode()); + resultObj.put("message", response.getMessage()); + postLog.setResult(resultObj); + paramObj.put("phone", phone); + paramObj.put("tmpCode", SmsUtils.SMS_217025172); + paramObj.put("signName", SmsUtils.SMS_SIGN_NAME); + postLog.setData(paramObj); + postLog.setSendTime(DateUtils.getNowDate()); + postLog.setType(2); + wxSubscribePostLogService.insertWxSubscribePostLog(postLog); + } catch (ClientException e) { + e.printStackTrace(); + } + + return reCode; + } + + @Override + public Integer checkSmsCode(String phone, String code) { + String cachedCode = redisService.get(phone); + int resCode = -1; + if (StringUtils.isEmpty(cachedCode)) { + // 验证码失效 + resCode = 1; + redisService.remove(phone); + } else if (!code.equals(cachedCode)) { + // 验证码错误 + resCode = 2; + } else if (code.equals(cachedCode)) { + // 校验成功 + resCode = 0; + redisService.remove(phone); + } + return resCode; + } +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WeChartAppletServiceImp.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WeChartAppletServiceImp.java index 73a40ee88..a148731fe 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WeChartAppletServiceImp.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WeChartAppletServiceImp.java @@ -29,9 +29,6 @@ import java.util.concurrent.TimeUnit; public class WeChartAppletServiceImp implements IWechatAppletService { static final String WX_TEM_ID = "Ow0j0Jt4OJhjy6GruBstOMLTGjAVagM4hTZRLAaxqJo"; - static final String SMS_TEM_ID = "SMS_216839183"; - static final String SMS_SIGN_NAME = "胜唐体控"; - @Autowired private RedisCache redisCache; @@ -128,7 +125,9 @@ public class WeChartAppletServiceImp implements IWechatAppletService { public Integer postSms(Long cusId, Long planId, String plan) { try { SysCustomer customer = sysCustomerService.selectSysCustomerById(cusId); - SendSmsResponse response = SmsUtils.sendSms(customer.getPhone(), plan, SMS_TEM_ID, SMS_SIGN_NAME); + JSONObject paramObj = new JSONObject(); + paramObj.put("plan", plan); + SendSmsResponse response = SmsUtils.sendSms(customer.getPhone(), paramObj.toJSONString(), SmsUtils.SMS_216839183, SmsUtils.SMS_SIGN_NAME); WxSubscribePostLog postLog = new WxSubscribePostLog(); postLog.setPhone(customer.getPhone()); @@ -142,8 +141,8 @@ public class WeChartAppletServiceImp implements IWechatAppletService { JSONObject dataParam = new JSONObject(); dataParam.put("phone", customer.getPhone()); dataParam.put("plan", plan); - dataParam.put("tmpCode", SMS_TEM_ID); - dataParam.put("signName", SMS_SIGN_NAME); + dataParam.put("tmpCode", SmsUtils.SMS_216839183); + dataParam.put("signName", SmsUtils.SMS_SIGN_NAME); postLog.setData(dataParam); postLog.setSendTime(DateUtils.getNowDate()); postLog.setType(1); diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/utils/SmsUtils.java b/stdiet-custom/src/main/java/com/stdiet/custom/utils/SmsUtils.java index 176842e27..c64a06d1e 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/utils/SmsUtils.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/utils/SmsUtils.java @@ -1,6 +1,5 @@ package com.stdiet.custom.utils; -import com.alibaba.fastjson.JSONObject; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsRequest; @@ -16,12 +15,42 @@ import java.text.SimpleDateFormat; import java.util.Date; public class SmsUtils { + /** + * 身份验证码 + */ + public static final String SMS_217025173 = "SMS_217025173"; + /** + * 登录确认验证码 + */ + public static final String SMS_217025172 = "SMS_217025172"; + /** + * 用户注册验证码 + */ + public static final String SMS_217025170 = "SMS_217025170"; + /** + * 修改密码验证码 + */ + public static final String SMS_217025169 = "SMS_217025169"; + /** + * 新食谱通知 + */ + public static final String SMS_216839183 = "SMS_216839183"; + + /** + * 签名 + */ + public static final String SMS_SIGN_NAME = "胜唐体控"; + //产品名称:云通信短信API产品,开发者无需替换 static final String product = "Dysmsapi"; //产品域名,开发者无需替换 static final String domain = "dysmsapi.aliyuncs.com"; - public static SendSmsResponse sendSms(String phone, String plan, String tmpCode, String signName) throws ClientException { + public static SendSmsResponse sendSms(String phone, String paramStr, String tmpCode) throws ClientException { + return sendSms(phone, paramStr, tmpCode, SMS_SIGN_NAME); + } + + public static SendSmsResponse sendSms(String phone, String paramStr, String tmpCode, String signName) throws ClientException { //可自助调整超时时间 System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); @@ -41,9 +70,7 @@ public class SmsUtils { //必填:短信模板-可在短信控制台中找到 request.setTemplateCode(tmpCode); //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 - JSONObject paramObj = new JSONObject(); - paramObj.put("plan", plan); - request.setTemplateParam(paramObj.toJSONString()); + request.setTemplateParam(paramStr); //选填-上行短信扩展码(无特殊需求用户请忽略此字段) //request.setSmsUpExtendCode("90997"); diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue index d0606d10e..7402a60ba 100644 --- a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue +++ b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue @@ -10,9 +10,11 @@ }`" @click="handleOnCustomerClick(customer)" > - - {{ customer.name && customer.name.substr(-1) }} - + + + {{ customer.name && customer.name.substr(-1) }} + + {{ customer.name }} @@ -38,11 +40,10 @@
{{ topic.content }}
-
by {{ topic.name }}
+
{{ formatDate(topic.createTime) }}
{{ topicTypeDict[topic.topicType] }} -
{{ formatDate(topic.createTime) }}
@@ -306,6 +307,9 @@ export default { .customer_name { margin-left: 8px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; } } @@ -362,22 +366,16 @@ export default { line-height: 1.5; } - .topic_user_name { - color: #8c8c8c; + .topic_time { font-size: 14px; - margin-top: 8px; + margin-top: 6px; + color: #8c8c8c; } } .topic_info { flex: 0 0 80px; text-align: center; - - .topic_time { - font-size: 14px; - margin-top: 8px; - color: #8c8c8c; - } } }