Authored by mali

优化查询性能

... ... @@ -26,4 +26,6 @@ public interface IInBoxDao {
InBox selectNewUserGuideInBox(@Param("tableName")String tableName, @Param("businessType") Integer businessType, @Param("uid") Integer uid);
int insertBatch(@Param("tableName") String tableName, @Param("list") List<InBox> list);
List<InBox> selectInboxsEx(@Param("tableName")String tableName, @Param("uid") int uid);
}
... ...
... ... @@ -79,4 +79,13 @@
</insert>
<select id="selectInboxsEx" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM ${tableName} where uid = #{uid} and is_del='N'
order by id desc
limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -418,7 +418,7 @@ public class InBoxServiceImpl implements IInBoxService {
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_VO_LAST_INFO.generateKey(uid);
InBox inbox = redisTemplate.get(inboxKey, InBox.class);
if (null == inbox) {
List<InBox> inBoxes = inBoxDao.selectInboxs(getTableName(uid), null, uid, 0, 1); //查询最新一条未读消息
List<InBox> inBoxes = inBoxDao.selectInboxsEx(getTableName(uid), uid); //查询最新一条未读消息
if(CollectionUtils.isNotEmpty(inBoxes)){
result.put("lastMessage", inBoxes.get(0).getContent());
result.put("createTime", inBoxes.get(0).getCreateTime());
... ...