From b26feec4eac18464a46b787b010b18f202e3aa9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E5=AE=87=E5=A5=87?= Date: Mon, 13 Oct 2025 17:21:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=97=A5=E4=B8=8B=E8=BD=BD=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=E9=99=90=E5=88=B6=EF=BC=8C=E9=87=8D=E7=BD=AE=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/constant/CacheConstants.java | 4 ++++ .../system/service/impl/SysUserServiceImpl.java | 5 ++++- .../xkt/service/impl/StoreProductServiceImpl.java | 13 +++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java index 36a97b82b..65e128e59 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java @@ -300,6 +300,10 @@ public class CacheConstants { * 图包用户请求次数缓存 */ public static final String PIC_PACK_USER_REQ_COUNT_CACHE = "pic_pack_user_req_count_cache:"; + /** + * 图包用户每日请求次数缓存 + */ + public static final String PIC_PACK_USER_DAILY_REQ_COUNT_CACHE = "pic_pack_user_daily_req_count_cache:"; /** * 充值单号缓存 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 07cb07430..fa746812d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -179,9 +179,12 @@ public class SysUserServiceImpl implements ISysUserService { @Transactional(rollbackFor = Exception.class) @Override public String resetPassword(Long userId, String password) { - if (userId == null || StrUtil.isEmpty(password)) { + if (userId == null) { return null; } + if (StrUtil.isEmpty(password)) { + password = configService.selectConfigByKey("sys.user.initPassword"); + } SysUser user = userMapper.selectById(userId); user.setPassword(SecurityUtils.encryptPassword(password)); updateUserBase(user, true); diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductServiceImpl.java index 24de67516..5cfd5eb8d 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreProductServiceImpl.java @@ -67,6 +67,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.stream.Collectors; @@ -640,7 +641,13 @@ public class StoreProductServiceImpl implements IStoreProductService { public PicPackInfoDTO getPicPackDownloadUrl(PicPackReqDTO picPackReqDTO) { Assert.notNull(picPackReqDTO.getUserId()); String reqCacheKey = CacheConstants.PIC_PACK_USER_REQ_COUNT_CACHE + picPackReqDTO.getUserId(); + String dailyReqCacheKey = CacheConstants.PIC_PACK_USER_DAILY_REQ_COUNT_CACHE + picPackReqDTO.getUserId(); int reqCount = Optional.ofNullable((Integer) redisCache.getCacheObject(reqCacheKey)).orElse(0); + int dailyReqCount = Optional.ofNullable((Integer) redisCache.getCacheObject(dailyReqCacheKey)).orElse(0); + //每日下载次数限制:50次 + if (dailyReqCount > 49) { + throw new ServiceException("您今日的免费下载限额(50款/日)已用完,请明日再来!如需扩大下载限额,请联系平台客服"); + } //5次请求后需要输入验证码 if (reqCount > 4) { //需验证验证码 @@ -669,6 +676,12 @@ public class StoreProductServiceImpl implements IStoreProductService { } //请求次数+1 redisCache.setCacheObject(reqCacheKey, reqCount + 1); + redisCache.setCacheObject(dailyReqCacheKey, dailyReqCount + 1); + if (0 == dailyReqCount) { + //每日首次下载 + long expire = DateUtil.endOfDay(new Date()).getTime() - System.currentTimeMillis(); + redisCache.expire(dailyReqCacheKey, expire, TimeUnit.MILLISECONDS); + } return new PicPackInfoDTO(file.getId(), file.getFileName(), file.getFileUrl(), file.getFileSize(), downloadUrl, false); }