新增书签设置星标功能 ,新增redis工具类规定时间内请求限制次数,新增阿里大鱼手机号发送验证码功能
This commit is contained in:
@ -56,6 +56,15 @@ public interface SqBookmarkMapper extends MyMapper<SqBookmark>
|
||||
*/
|
||||
public int updateSqBookmark(SqBookmark sqBookmark);
|
||||
|
||||
/**
|
||||
* 设置书签的星标
|
||||
*
|
||||
* @param bookmarkId
|
||||
* @param userId
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSqBookmarkByStar(@Param("bookmarkId") Long bookmarkId,@Param("userId")Long userId,@Param("bookmarkStar") Integer bookmarkStar);
|
||||
|
||||
/**
|
||||
* 删除书签管理
|
||||
*
|
||||
|
@ -132,7 +132,7 @@ public interface ISqBookmarkService
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
int updateBookmarkStarById(Long userId, String bookmarkId, int bookmarkStr);
|
||||
int updateBookmarkStarById(Long userId, Long bookmarkId, Integer bookmarkStr);
|
||||
/**
|
||||
* 删除重复的书签
|
||||
*
|
||||
|
@ -127,7 +127,7 @@ public interface ISqMenuService
|
||||
|
||||
|
||||
/**
|
||||
*防止重复点击上传文件
|
||||
*防止重复点击
|
||||
*
|
||||
* @param state 表示某个功能
|
||||
* @param userID 用户ID
|
||||
@ -183,4 +183,16 @@ public interface ISqMenuService
|
||||
* @return
|
||||
*/
|
||||
List<SqMenu> listByMenuId(Long userId, Long menuId);
|
||||
|
||||
/**
|
||||
*
|
||||
* 显示l时间内 只能访问i次
|
||||
*
|
||||
* @param phoneRegister 功能标识符
|
||||
* @param userId 用户id
|
||||
* @param time 时间单位秒
|
||||
* @param i 次数
|
||||
* @return
|
||||
*/
|
||||
Boolean countRepetition(String phoneRegister, Long userId, long time, int i);
|
||||
}
|
||||
|
@ -375,12 +375,8 @@ public class SqBookmarkServiceImpl implements ISqBookmarkService
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateBookmarkStarById(Long userId, String bookmarkId, int bookmarkStr) {
|
||||
SqBookmark sqBookmark =new SqBookmark();
|
||||
sqBookmark.setBookmarkId(Long.valueOf(bookmarkId));
|
||||
sqBookmark.setUserid(userId);
|
||||
sqBookmark.setBookmarkStar(bookmarkStr==1?1:0);
|
||||
return sqBookmarkMapper.updateSqBookmark(sqBookmark);
|
||||
public int updateBookmarkStarById(Long userId, Long bookmarkId, Integer bookmarkStr) {
|
||||
return sqBookmarkMapper.updateSqBookmarkByStar(bookmarkId,userId,bookmarkStr==1?1:0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,11 +2,14 @@ package com.ruoyi.bookmark.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ruoyi.common.core.redis.RedisKey;
|
||||
import com.ruoyi.common.core.redis.RedisUtil;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
||||
@ -221,14 +224,14 @@ public class SqMenuServiceImpl implements ISqMenuService
|
||||
*/
|
||||
@Override
|
||||
public Long noRepetition(String state, Long userID, Long time) {
|
||||
String key = "BookMark:"+state+":"+userID.toString();
|
||||
String str = redisUtil.get(key);
|
||||
if (str==null){
|
||||
redisUtil.setEx(key,"0",time,TimeUnit.SECONDS);
|
||||
return 0L;
|
||||
}else{
|
||||
return redisUtil.getExpire(key);
|
||||
}
|
||||
String key = RedisKey.BOOKMARK + state + RedisKey.CONNECTOR + userID.toString();
|
||||
String str = redisUtil.get(key);
|
||||
if (str == null) {
|
||||
redisUtil.setEx(key, "0", time, TimeUnit.SECONDS);//秒
|
||||
return 0L;
|
||||
} else {
|
||||
return redisUtil.getExpire(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,4 +333,31 @@ public class SqMenuServiceImpl implements ISqMenuService
|
||||
return sqMenuMapper.selectSqMenuList(new SqMenu(parentId,userId));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean countRepetition(String state, Long userId, long time, int i) {
|
||||
|
||||
String key = RedisKey.BOOKMARK + state + RedisKey.CONNECTOR + userId.toString();
|
||||
Long count = redisUtil.lLen(key);
|
||||
if (count.intValue() < i) {
|
||||
//插入到尾部
|
||||
redisUtil.lRightPush(key, String.valueOf(DateUtil.date(System.currentTimeMillis()).getTime()));
|
||||
redisUtil.expire(key, time, TimeUnit.SECONDS); //设置过期时间(秒)
|
||||
} else {
|
||||
//获取最新第一条 判断是否满足规定时间内的访问次数
|
||||
String indexTime = redisUtil.lIndex(key, 0);
|
||||
|
||||
if (TimeUnit.MILLISECONDS.toSeconds(DateUtil.date(System.currentTimeMillis()).getTime() - Long.valueOf(indexTime)) < time) // 触发10min内请求大于3次,提醒,“请求过多,请稍后再试。”
|
||||
{
|
||||
return false;
|
||||
} else {
|
||||
//将当前时间戳插入List头部
|
||||
redisUtil.lLeftPush(key, String.valueOf(DateUtil.date(System.currentTimeMillis()).getTime()));
|
||||
redisUtil.lTrim(key, 0, i - 1); //剪切 0 到i个数
|
||||
redisUtil.expire(key, time, TimeUnit.SECONDS); //设置过期时间(秒)
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -102,15 +102,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="zcount != null">zcount = #{zcount},</if>
|
||||
<if test="idelete != null">idelete = #{idelete},</if>
|
||||
<if test="start != null">start = #{start},</if>
|
||||
<if test="bookmarkStar != null">bookmark_star = #{bookmarkStar},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
where bookmark_id = #{bookmarkId}
|
||||
</update>
|
||||
|
||||
<update id="updateSqBookmarkByStar" parameterType="SqBookmark">
|
||||
update sq_bookmark SET bookmark_star = #{bookmarkStar} where bookmark_id = #{bookmarkId} and userid = #{userId}
|
||||
</update>
|
||||
|
||||
<update id="updateSqBookmarkBymenuId" parameterType="Long">
|
||||
update sq_bookmark set IDelete = 1 where menu_id = #{menuId}
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteSqBookmarkById" parameterType="Long">
|
||||
delete from sq_bookmark where bookmark_id = #{bookmarkId}
|
||||
</delete>
|
||||
@ -145,7 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectSqBookmarkVo"/>
|
||||
where userid=#{userID}
|
||||
<if test="sousuo == null or sousuo == ''"> and menu_id = #{menuID}</if>
|
||||
<if test="bookmarkStar != null and bookmarkStar != ''"> and bookmark_star = #{bookmarkStar}</if>
|
||||
|
||||
<if test="start != null and start != ''"> and start = #{start}</if>
|
||||
<if test="sousuo != null and sousuo != ''"> and title like concat('%', #{sousuo}, '%')</if>
|
||||
order by
|
||||
|
Reference in New Issue
Block a user