zouxuan 5 years ago
parent
commit
8548bed78f

+ 9 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMessageServiceImpl.java

@@ -5,11 +5,14 @@ import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Random;
 import java.util.Random;
 
 
+import com.ym.mec.common.redis.service.RedisCache;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -49,7 +52,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 	private SysUserFeignService sysUserFeignService;
 	private SysUserFeignService sysUserFeignService;
 
 
 	@Autowired
 	@Autowired
-	private Cache redisCache;
+	private RedisTemplate redisTemplate;
 
 
 	// 验证码有效期
 	// 验证码有效期
 	public static final int CODE_EXPIRE = 60 * 5;
 	public static final int CODE_EXPIRE = 60 * 5;
@@ -216,6 +219,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 	@Override
 	@Override
 	public boolean sendSecurityCode(MessageSender messageSender, Integer userId, SendTypeEnum mode, MessageType messageType, String receiver) {
 	public boolean sendSecurityCode(MessageSender messageSender, Integer userId, SendTypeEnum mode, MessageType messageType, String receiver) {
 		String key1 = getVerificationCode1CacheKey(messageType, receiver);
 		String key1 = getVerificationCode1CacheKey(messageType, receiver);
+		ValueOperations redisCache = redisTemplate.opsForValue();
 		if (redisCache.get(key1) != null) {
 		if (redisCache.get(key1) != null) {
 			throw new BizException("请勿频繁操作,获取验证码间隔时间为60秒");
 			throw new BizException("请勿频繁操作,获取验证码间隔时间为60秒");
 		}
 		}
@@ -226,8 +230,8 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 			code = getRandomCode(messageType, receiver);
 			code = getRandomCode(messageType, receiver);
 		}
 		}
 		sendMessage(messageSender, userId, mode, messageType, receiver, null, 1, "", code);
 		sendMessage(messageSender, userId, mode, messageType, receiver, null, 1, "", code);
-		redisCache.put(key, code, CODE_EXPIRE);
-		redisCache.put(key1, code, CODE_INTERVAL_TIME);
+		redisCache.set(key, code, CODE_EXPIRE);
+		redisCache.set(key1, code, CODE_INTERVAL_TIME);
 		return true;
 		return true;
 	}
 	}
 
 
@@ -237,6 +241,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 			return DEFAULT_CODE + "";
 			return DEFAULT_CODE + "";
 		}
 		}
 		String key = getVerificationCodeCacheKey(type, mobileNOOrEmailAddr);
 		String key = getVerificationCodeCacheKey(type, mobileNOOrEmailAddr);
+		ValueOperations redisCache = redisTemplate.opsForValue();
 		Object object = redisCache.get(key);
 		Object object = redisCache.get(key);
 		return object == null ? null : object.toString();
 		return object == null ? null : object.toString();
 	}
 	}
@@ -245,7 +250,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 	public void delSendedVerificationCode(MessageType type, String mobileNOOrEmailAddr) {
 	public void delSendedVerificationCode(MessageType type, String mobileNOOrEmailAddr) {
 		String key = getVerificationCodeCacheKey(type, mobileNOOrEmailAddr);
 		String key = getVerificationCodeCacheKey(type, mobileNOOrEmailAddr);
 		if (StringUtils.isNotBlank(key)) {
 		if (StringUtils.isNotBlank(key)) {
-			redisCache.delete(key);
+			redisTemplate.delete(key);
 		}
 		}
 	}
 	}
 
 

+ 4 - 4
mec-biz/src/main/resources/config/mybatis/SysMessageMapper.xml

@@ -59,7 +59,7 @@
 		id_ = #{id,jdbcType=BIGINT}
 		id_ = #{id,jdbcType=BIGINT}
 	</delete>
 	</delete>
 
 
-	<insert id="insert" parameterType="com.ljfq.xjd.dal.model.Message">
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SysMessage">
 		insert into sys_message (id_, user_id_,
 		insert into sys_message (id_, user_id_,
 		title_, content_,
 		title_, content_,
 		type_, status_, receiver_,
 		type_, status_, receiver_,
@@ -74,7 +74,7 @@
 		#{modifyOn})
 		#{modifyOn})
 	</insert>
 	</insert>
 
 
-	<insert id="batchInsert" parameterType="com.ljfq.xjd.dal.model.Message">
+	<insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.SysMessage">
 		insert into sys_message (id_, user_id_,
 		insert into sys_message (id_, user_id_,
 		title_, content_,
 		title_, content_,
 		type_, status_, receiver_,
 		type_, status_, receiver_,
@@ -95,7 +95,7 @@
 		</foreach>
 		</foreach>
 	</insert>
 	</insert>
 
 
-	<update id="update" parameterType="com.ljfq.xjd.dal.model.Message">
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.SysMessage">
 		update sys_message
 		update sys_message
 		<set>
 		<set>
 			<if test="userId != null">
 			<if test="userId != null">
@@ -147,7 +147,7 @@
 		where id_ =#{id}
 		where id_ =#{id}
     </update>
     </update>
 
 
-    <select id="findCount" parameterType="map" resultType="int">
+    <select id="queryCount" parameterType="map" resultType="int">
 		select count(*) from sys_message
 		select count(*) from sys_message
 		<include refid="queryCondition" />
 		<include refid="queryCondition" />
 	</select>
 	</select>