Browse Source

短信登录、绑定运营人员

huangzhiguo 2 years ago
parent
commit
50bc9d0cd6

+ 15 - 0
src/main/java/com/caimei365/user/service/impl/BaseServiceImpl.java

@@ -25,6 +25,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
@@ -343,11 +344,19 @@ public class BaseServiceImpl implements BaseService {
      */
      */
     @Override
     @Override
     public ResponseJson getLoginCode(String mobile) {
     public ResponseJson getLoginCode(String mobile) {
+
         // 验证手机号
         // 验证手机号
         String result = ValidateUtil.validateMobile(mobile);
         String result = ValidateUtil.validateMobile(mobile);
         if (result != null) {
         if (result != null) {
             return ResponseJson.error(result);
             return ResponseJson.error(result);
         }
         }
+
+        Object resCode = redisService.get("code:" + mobile);
+        long expireTime = redisService.getExpireTime("code:" + mobile);
+        if (!ObjectUtils.isEmpty(resCode) || expireTime >= 0) {
+            return ResponseJson.error("验证码已发送,请勿重复操作");
+        }
+
         Integer dbUserId = null;
         Integer dbUserId = null;
         // 根据手机号查询用户Id
         // 根据手机号查询用户Id
         dbUserId = baseMapper.getUserIdByMobile(mobile);
         dbUserId = baseMapper.getUserIdByMobile(mobile);
@@ -390,6 +399,12 @@ public class BaseServiceImpl implements BaseService {
         if (result != null) {
         if (result != null) {
             return ResponseJson.error(result);
             return ResponseJson.error(result);
         }
         }
+        Object resCode = redisService.get("code:" + mobile);
+        long expireTime = redisService.getExpireTime("code:" + mobile);
+        if (!ObjectUtils.isEmpty(resCode) || expireTime >= 0) {
+            return ResponseJson.error("验证码已发送,请勿重复操作");
+        }
+
         Integer dbUserId = null;
         Integer dbUserId = null;
         // 根据手机号查询用户Id
         // 根据手机号查询用户Id
         dbUserId = baseMapper.getUserIdByMobile(mobile);
         dbUserId = baseMapper.getUserIdByMobile(mobile);

+ 9 - 6
src/main/resources/mapper/BaseMapper.xml

@@ -28,12 +28,15 @@
         limit 1
         limit 1
     </select>
     </select>
     <select id="getUserIdByMobile" resultType="java.lang.Integer">
     <select id="getUserIdByMobile" resultType="java.lang.Integer">
-        select u.userID from user u
-        left join cm_mall_operation_user cu on cu.userID = u.userID
-        where (u.bindMobile = #{mobile}
-                or (cu.mobile = #{mobile} and cu.delFlag != 1)
-        ) and u.userIdentity in (1,2,3,4)
-        limit 1
+        SELECT u.userID FROM USER u
+            LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
+        WHERE u.bindMobile = #{mobile} and u.userIdentity in (1,2,3,4)
+        UNION
+        SELECT u.userID FROM USER u
+            LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
+        WHERE cu.mobile = #{mobile} AND cu.delFlag != 1
+          AND u.userIdentity IN (1,2,3,4)
+        LIMIT 1
     </select>
     </select>
     <select id="getOperationUserIdByMobile" resultType="java.lang.Integer">
     <select id="getOperationUserIdByMobile" resultType="java.lang.Integer">
         select userID from cm_mall_operation_user
         select userID from cm_mall_operation_user