Commit abbf0ec8 by 阮思源

Merge branch 'fix-rsy' into 'master'

发识别码错误和请按以上指引回复准确的内容以便获取对应服务加1小时缓存

See merge request rays/pcloud-book!311
parents 54a02094 b51cce55
......@@ -183,6 +183,10 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
*/
private static final Integer LE = 1000;
private static final String REPLY_GUIDE_CACHE = "BOOK:replyGuideCache";
private static final String REPLY_ERROR_SHORT_BOOK_NAME_CACHE = "BOOK:replyErrorShortBookNameCache";
@Override
@ParamLog("新增关键词")
@Transactional(rollbackFor = Exception.class)
......@@ -531,7 +535,14 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
BookGroup bookGroup = bookGroupDao.getByShortBookName(content);
if (bookGroup == null) {
//既不是关键词也不是识别码
sendText(sendTextDTO, "请按以上指引回复准确的内容以便获取对应服务,谢谢!");
String altIdAndWxId = sendTextDTO.getWxId() + "_" + sendTextDTO.getWechatUserId();
Integer send = JedisClusterUtils.hgetJson2Class(REPLY_GUIDE_CACHE, altIdAndWxId, Integer.class);
if (send == null) {
sendText(sendTextDTO, "请按以上指引回复准确的内容以便获取对应服务,谢谢!");
JedisClusterUtils.hset2Json(REPLY_GUIDE_CACHE, altIdAndWxId, 1);
//1小时缓存
JedisClusterUtils.expire(REPLY_GUIDE_CACHE, 60 * 60 * 1);
}
}
}
}
......@@ -620,7 +631,14 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
//判断之前是否有关联,如果没有,提示输入正确的识别码
Long bookGroupId = bookGroupCipherUserDao.getBookGroupIdByWxUserId(sendTextDTO.getWechatUserId());
if (bookGroupId == null) {
sendText(sendTextDTO, "识别码发送错误,请核对后重新发送。");
String altIdAndWxId = sendTextDTO.getWxId() + "_" + sendTextDTO.getWechatUserId();
Integer send = JedisClusterUtils.hgetJson2Class(REPLY_ERROR_SHORT_BOOK_NAME_CACHE, altIdAndWxId, Integer.class);
if (send == null) {
sendText(sendTextDTO, "识别码发送错误,请核对后重新发送。");
JedisClusterUtils.hset2Json(REPLY_ERROR_SHORT_BOOK_NAME_CACHE, altIdAndWxId, 1);
//1小时缓存
JedisClusterUtils.expire(altIdAndWxId, 60 * 60 * 1);
}
}
}
}
......
......@@ -182,7 +182,15 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
@Override
public String getMaxKeyword(Long bookGroupId) {
return selfRobotKeywordDao.getMaxKeyword(bookGroupId);
List<String> keywords = selfRobotKeywordDao.getKeywords(bookGroupId);
Integer max = 0;
for (String keyword : keywords) {
Integer iKeyword = new Integer(keyword);
if (iKeyword > max) {
max = iKeyword;
}
}
return max.toString();
}
@ParamLog("填充列表")
......
......@@ -28,5 +28,5 @@ public interface SelfRobotKeywordDao extends BaseDao<SelfRobotKeyword> {
void updateSeqNum(Long id, Integer seqNum);
String getMaxKeyword(Long bookGroupId);
List<String> getKeywords(Long bookGroupId);
}
......@@ -72,9 +72,9 @@ public class SelfRobotKeywordDaoImpl extends BaseDaoImpl<SelfRobotKeyword> imple
}
@Override
public String getMaxKeyword(Long bookGroupId) {
public List<String> getKeywords(Long bookGroupId) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
return this.getSqlSession().selectOne(this.getStatement("getMaxKeyword"), map);
return this.getSqlSession().selectList(this.getStatement("getKeywords"), map);
}
}
......@@ -189,9 +189,9 @@
where id=#{id}
</update>
<!--获取最大关键词-->
<select id="getMaxKeyword" parameterType="map" resultType="string">
select max(keyword) from self_robot_keyword
<!--获取关键词列表-->
<select id="getKeywords" parameterType="map" resultType="string">
select keyword from self_robot_keyword
where book_group_id=#{bookGroupId}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment