123
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.cai.cache;
|
||||
|
||||
import com.ruoyi.cai.constant.RedisConstant;
|
||||
import com.ruoyi.cai.constant.RedisHttpConstant;
|
||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,7 +22,7 @@ public class DynamicTotalCache {
|
||||
|
||||
public String getKey(Long userId){
|
||||
String now = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
return String.format(RedisConstant.DYNAMIC_TOTAL_CACHE_REDIS,now,userId);
|
||||
return String.format(RedisHttpConstant.DYNAMIC_TOTAL_CACHE_REDIS,now,userId);
|
||||
}
|
||||
|
||||
public void add(Long userId){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.cai.constant;
|
||||
|
||||
public class RedisConstant {
|
||||
public class RedisHttpConstant {
|
||||
public static final String REDIS_P = "cai-";
|
||||
public static final String SYSTEM_CONFIG = REDIS_P + "system-config";
|
||||
public static final String CITY_CACHE_REDIS = REDIS_P + "city";
|
||||
@@ -12,5 +12,8 @@ public class RedisConstant {
|
||||
public static final String FORBID_CACHE_REDIS = REDIS_P + "forbid:%s";
|
||||
public static final String LOVE_RANK_REDIS = REDIS_P + "loveRank:%s:%s";
|
||||
public static final String INVITE_RANK_REDIS = REDIS_P + "inviteRank:%s:%s";
|
||||
public static final String HOME_RECOMMEND_REDIS = REDIS_P + "homeRecommendAnchor";
|
||||
public static final String HOME_NEW_REDIS = REDIS_P + "homeNewAnchor";
|
||||
public static final String HOME_ACTIVE_REDIS = REDIS_P + "homeActiveAnchor";
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.ruoyi.cai.dto.app.vo.index.GuardListPageVo;
|
||||
import com.ruoyi.cai.dto.app.vo.index.UserGiftIndexVo;
|
||||
import com.ruoyi.cai.dto.app.vo.user.UserInfoVo;
|
||||
import com.ruoyi.cai.dto.app.vo.user.UserListVo;
|
||||
import com.ruoyi.cai.manager.HomeManager;
|
||||
import com.ruoyi.cai.service.*;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
@@ -42,6 +43,8 @@ public class IndexController {
|
||||
private GuardTotalService guardTotalService;
|
||||
@Autowired
|
||||
private UserGiftService userGiftService;
|
||||
@Autowired
|
||||
private HomeManager homeManager;
|
||||
|
||||
@GetMapping("/banner")
|
||||
@Operation(summary = "获取首页banner图")
|
||||
@@ -54,7 +57,15 @@ public class IndexController {
|
||||
@GetMapping("/anchor/page")
|
||||
@Operation(summary = "首页查询主播接口-分页")
|
||||
@Log(title = "首页查询主播接口", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
public R<List<AnchorListVo>> page(PageQuery page, AnchorListQuery query){
|
||||
public R<List<AnchorListVo>> anchorPage(PageQuery page, AnchorListQuery query){
|
||||
List<AnchorListVo> home = homeManager.getHomeCache(page, query);
|
||||
return R.ok(home);
|
||||
}
|
||||
|
||||
@GetMapping("/anchor/test/page")
|
||||
@Operation(summary = "主播测试接口")
|
||||
@Log(title = "主播测试接口", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
public R<List<AnchorListVo>> anchorTestPage(PageQuery page, AnchorListQuery query){
|
||||
Page<AnchorListVo> res = anchorService.pageApp(page,query);
|
||||
return R.ok(res.getRecords());
|
||||
}
|
||||
@@ -62,7 +73,7 @@ public class IndexController {
|
||||
@GetMapping("/user/page")
|
||||
@Operation(summary = "首页用户搜索接口-分页")
|
||||
@Log(title = "首页用户搜索接口-分页", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
public R<List<UserListVo>> page(PageQuery page, UserQuery query){
|
||||
public R<List<UserListVo>> userPage(PageQuery page, UserQuery query){
|
||||
Page<UserListVo> res = userService.pageApp(page,query);
|
||||
return R.ok(res.getRecords());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.ruoyi.cai.enums.home;
|
||||
|
||||
import lombok.Getter;
|
||||
/**
|
||||
* 0-默认查询
|
||||
* 1-活跃查询
|
||||
* 2-新人查询
|
||||
* 3-同城查询
|
||||
*/
|
||||
@Getter
|
||||
public enum AnchorListQueryTypeEnum {
|
||||
DEFAULT(0,"默认查询"),
|
||||
ACTIVE(1,"活跃查询"),
|
||||
NEW(2,"新人查询"),
|
||||
CITY(3,"同城查询"),
|
||||
;
|
||||
private final Integer code;
|
||||
private final String text;
|
||||
|
||||
AnchorListQueryTypeEnum(Integer code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public static AnchorListQueryTypeEnum getByCode(Integer code){
|
||||
AnchorListQueryTypeEnum[] values = AnchorListQueryTypeEnum.values();
|
||||
for (AnchorListQueryTypeEnum value : values) {
|
||||
if(value.getCode().equals(code)){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return AnchorListQueryTypeEnum.DEFAULT;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ruoyi.cai.job;
|
||||
|
||||
import com.ruoyi.cai.manager.HomeManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class HomeRecommendJob {
|
||||
|
||||
@Autowired
|
||||
private HomeManager homeManager;
|
||||
|
||||
|
||||
// 每6分钟执行一次
|
||||
@Scheduled(cron = "0 0/6 * * * ? ")
|
||||
public void clearRun() {
|
||||
try {
|
||||
homeManager.refreshHomeActiveCache();
|
||||
}catch (Exception e){
|
||||
log.error("刷新首页活跃用户失败",e);
|
||||
}
|
||||
try {
|
||||
homeManager.refreshHomeNewCache();
|
||||
}catch (Exception e){
|
||||
log.error("刷新首页新用户失败",e);
|
||||
}
|
||||
try {
|
||||
homeManager.refreshHomeRecommendCache();
|
||||
}catch (Exception e){
|
||||
log.error("刷新首页推荐用户失败",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ruoyi.cai.manager;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.ruoyi.cai.constant.RedisConstant;
|
||||
import com.ruoyi.cai.constant.RedisHttpConstant;
|
||||
import com.ruoyi.cai.enums.CodeEnum;
|
||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -20,7 +20,7 @@ public class CodeManager {
|
||||
private SystemConfigManager systemConfigManager;
|
||||
|
||||
public String getKey(CodeEnum codeEnum,String phone){
|
||||
return String.format(RedisConstant.CODE_REDIS,codeEnum.name(),phone);
|
||||
return String.format(RedisHttpConstant.CODE_REDIS,codeEnum.name(),phone);
|
||||
}
|
||||
|
||||
public void put(CodeEnum codeEnum,String phone,String code){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.cai.manager;
|
||||
|
||||
import com.ruoyi.cai.constant.RedisConstant;
|
||||
import com.ruoyi.cai.constant.RedisHttpConstant;
|
||||
import com.ruoyi.cai.domain.UserForbid;
|
||||
import com.ruoyi.cai.enums.ForbidTypeEnum;
|
||||
import com.ruoyi.cai.ws.util.MapGetUtil;
|
||||
@@ -16,7 +16,7 @@ public class ForbidCache {
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
private String getKey(Integer type){
|
||||
return String.format(RedisConstant.FORBID_CACHE_REDIS,type);
|
||||
return String.format(RedisHttpConstant.FORBID_CACHE_REDIS,type);
|
||||
}
|
||||
|
||||
public void addForbid(UserForbid userForbid){
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.ruoyi.cai.manager;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.constant.RedisHttpConstant;
|
||||
import com.ruoyi.cai.dto.app.query.index.AnchorListQuery;
|
||||
import com.ruoyi.cai.dto.app.vo.AnchorListVo;
|
||||
import com.ruoyi.cai.enums.home.AnchorListQueryTypeEnum;
|
||||
import com.ruoyi.cai.service.AnchorService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import org.redisson.api.RBucket;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页主播随机推荐
|
||||
*/
|
||||
@Component
|
||||
public class HomeManager {
|
||||
|
||||
@Autowired
|
||||
private AnchorService anchorService;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
public void refreshHomeRecommendCache(){
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageSize(200);
|
||||
pageQuery.setPageNum(1);
|
||||
AnchorListQuery query = new AnchorListQuery();
|
||||
// 0-默认查询 1-活跃查询 2-新人查询 3-同城查询
|
||||
query.setType(0);
|
||||
Page<AnchorListVo> app = anchorService.pageApp(pageQuery, query);
|
||||
List<AnchorListVo> records = app.getRecords();
|
||||
RBucket<List<AnchorListVo>> bucket = redissonClient.getBucket(RedisHttpConstant.HOME_RECOMMEND_REDIS);
|
||||
bucket.set(records);
|
||||
}
|
||||
|
||||
public void refreshHomeNewCache(){
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageSize(200);
|
||||
pageQuery.setPageNum(1);
|
||||
AnchorListQuery query = new AnchorListQuery();
|
||||
// 0-默认查询 1-活跃查询 2-新人查询 3-同城查询
|
||||
query.setType(1);
|
||||
Page<AnchorListVo> app = anchorService.pageApp(pageQuery, query);
|
||||
List<AnchorListVo> records = app.getRecords();
|
||||
RBucket<List<AnchorListVo>> bucket = redissonClient.getBucket(RedisHttpConstant.HOME_NEW_REDIS);
|
||||
bucket.set(records);
|
||||
}
|
||||
|
||||
public void refreshHomeActiveCache(){
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageSize(200);
|
||||
pageQuery.setPageNum(1);
|
||||
AnchorListQuery query = new AnchorListQuery();
|
||||
// 0-默认查询 1-活跃查询 2-新人查询 3-同城查询
|
||||
query.setType(2);
|
||||
Page<AnchorListVo> app = anchorService.pageApp(pageQuery, query);
|
||||
List<AnchorListVo> records = app.getRecords();
|
||||
RBucket<List<AnchorListVo>> bucket = redissonClient.getBucket(RedisHttpConstant.HOME_ACTIVE_REDIS);
|
||||
bucket.set(records);
|
||||
}
|
||||
|
||||
|
||||
public List<AnchorListVo> getHomeCache(PageQuery pageQuery,AnchorListQuery query){
|
||||
AnchorListQueryTypeEnum anchorListQueryTypeEnum = AnchorListQueryTypeEnum.getByCode(query.getType());
|
||||
List<AnchorListVo> vos;
|
||||
if(anchorListQueryTypeEnum == AnchorListQueryTypeEnum.DEFAULT){ // 默认
|
||||
RBucket<List<AnchorListVo>> bucket = redissonClient.getBucket(RedisHttpConstant.HOME_RECOMMEND_REDIS);
|
||||
vos = bucket.get();
|
||||
}else if(anchorListQueryTypeEnum == AnchorListQueryTypeEnum.ACTIVE){
|
||||
RBucket<List<AnchorListVo>> bucket = redissonClient.getBucket(RedisHttpConstant.HOME_ACTIVE_REDIS);
|
||||
vos = bucket.get();
|
||||
}else if(anchorListQueryTypeEnum == AnchorListQueryTypeEnum.NEW){
|
||||
RBucket<List<AnchorListVo>> bucket = redissonClient.getBucket(RedisHttpConstant.HOME_NEW_REDIS);
|
||||
vos = bucket.get();
|
||||
} else {
|
||||
if(query.getCityId() == null){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return anchorService.pageApp(pageQuery, query).getRecords();
|
||||
}
|
||||
Collections.shuffle(vos);
|
||||
Integer pageNum = pageQuery.getPageNum();
|
||||
int startIndex = (pageNum - 1) * pageQuery.getPageSize();
|
||||
int endIndex = Math.min(startIndex+pageQuery.getPageSize(), vos.size());
|
||||
return vos.subList(startIndex, endIndex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.ruoyi.cai.manager;
|
||||
|
||||
import com.ruoyi.cai.constant.RedisConstant;
|
||||
import com.ruoyi.cai.constant.RedisHttpConstant;
|
||||
|
||||
public class LockManager {
|
||||
|
||||
public static final String LOCK_REGISTER_REDIS = RedisConstant.REDIS_P + "lock:register:%s";
|
||||
public static final String LOCK_DEAL_INVITE_REDIS = RedisConstant.REDIS_P + "lock:dealInvite:%s";
|
||||
public static final String LOCK_ADD_USER_GREET_REDIS = RedisConstant.REDIS_P + "lock:addUserGreet:%s";
|
||||
public static final String LOCK_SEND_GREET_REDIS = RedisConstant.REDIS_P + "lock:sendGreet:%s";
|
||||
public static final String LOCK_SEND_GUARD_REDIS = RedisConstant.REDIS_P + "lock:sendGuard:%s";
|
||||
public static final String LOCK_SEND_GIFT_REDIS = RedisConstant.REDIS_P + "lock:sendGift:%s";
|
||||
public static final String LOCK_VIDEO_SETTLE_REDIS = RedisConstant.REDIS_P + "lock:videoSettle:%s";
|
||||
public static final String LOCK_REGISTER_REDIS = RedisHttpConstant.REDIS_P + "lock:register:%s";
|
||||
public static final String LOCK_DEAL_INVITE_REDIS = RedisHttpConstant.REDIS_P + "lock:dealInvite:%s";
|
||||
public static final String LOCK_ADD_USER_GREET_REDIS = RedisHttpConstant.REDIS_P + "lock:addUserGreet:%s";
|
||||
public static final String LOCK_SEND_GREET_REDIS = RedisHttpConstant.REDIS_P + "lock:sendGreet:%s";
|
||||
public static final String LOCK_SEND_GUARD_REDIS = RedisHttpConstant.REDIS_P + "lock:sendGuard:%s";
|
||||
public static final String LOCK_SEND_GIFT_REDIS = RedisHttpConstant.REDIS_P + "lock:sendGift:%s";
|
||||
public static final String LOCK_VIDEO_SETTLE_REDIS = RedisHttpConstant.REDIS_P + "lock:videoSettle:%s";
|
||||
|
||||
public static String getRegisterLockKey(String mobile){
|
||||
return String.format(LOCK_REGISTER_REDIS,mobile);
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.ruoyi.cai.manager;
|
||||
|
||||
import com.ruoyi.cai.constant.RedisConstant;
|
||||
import com.ruoyi.cai.constant.RedisHttpConstant;
|
||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||
import com.ruoyi.cai.enums.systemconfig.SystemCheckResp;
|
||||
import com.ruoyi.common.core.service.SensitiveService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.availability.AvailabilityChangeEvent;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -93,7 +92,7 @@ public class SystemConfigManager {
|
||||
* @return
|
||||
*/
|
||||
public String getSystemConfig(SystemConfigEnum systemConfig){
|
||||
String value = (String) redisTemplate.opsForHash().get(RedisConstant.SYSTEM_CONFIG, systemConfig.name());
|
||||
String value = (String) redisTemplate.opsForHash().get(RedisHttpConstant.SYSTEM_CONFIG, systemConfig.name());
|
||||
if(StringUtils.isBlank(value)){
|
||||
return systemConfig.getDefaultValue();
|
||||
}
|
||||
@@ -124,7 +123,7 @@ public class SystemConfigManager {
|
||||
*/
|
||||
public Map<String,String> getAllSystemConfig(){
|
||||
HashOperations<String, String, String> stringObjectObjectHashOperations = redisTemplate.opsForHash();
|
||||
return stringObjectObjectHashOperations.entries(RedisConstant.SYSTEM_CONFIG);
|
||||
return stringObjectObjectHashOperations.entries(RedisHttpConstant.SYSTEM_CONFIG);
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +142,6 @@ public class SystemConfigManager {
|
||||
if(key.equals(SystemConfigEnum.SENSITIVE_ENABLE.getKey())){
|
||||
sensitiveService.setSensitive(value.equals("1"));
|
||||
}
|
||||
redisTemplate.opsForHash().put(RedisConstant.SYSTEM_CONFIG, key,value);
|
||||
redisTemplate.opsForHash().put(RedisHttpConstant.SYSTEM_CONFIG, key,value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.cai.rank;
|
||||
|
||||
import com.ruoyi.cai.constant.RedisConstant;
|
||||
import com.ruoyi.cai.constant.RedisHttpConstant;
|
||||
import com.ruoyi.cai.mq.AmqpProducer;
|
||||
import com.ruoyi.cai.mq.handle.dto.RankDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -25,8 +25,8 @@ public class RankManager {
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
public static final String LOVE_KEY_FORMAT = RedisConstant.LOVE_RANK_REDIS;
|
||||
public static final String INVITE_KEY_FORMAT = RedisConstant.INVITE_RANK_REDIS;
|
||||
public static final String LOVE_KEY_FORMAT = RedisHttpConstant.LOVE_RANK_REDIS;
|
||||
public static final String INVITE_KEY_FORMAT = RedisHttpConstant.INVITE_RANK_REDIS;
|
||||
|
||||
public static final String DAY = "Day";
|
||||
public static final String WEEK = "Week";
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.ruoyi.cai.service.impl;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.constant.RedisConstant;
|
||||
import com.ruoyi.cai.constant.RedisHttpConstant;
|
||||
import com.ruoyi.cai.domain.Citys;
|
||||
import com.ruoyi.cai.mapper.CitysMapper;
|
||||
import com.ruoyi.cai.service.CitysService;
|
||||
@@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -39,18 +38,18 @@ public class CitysServiceImpl extends ServiceImpl<CitysMapper, Citys> implements
|
||||
public void resetRedis(){
|
||||
List<Citys> list = this.list();
|
||||
Map<String, String> map = list.stream().collect(Collectors.toMap(i -> String.valueOf(i.getId()), Citys::getName));
|
||||
redisTemplate.opsForHash().putAll(RedisConstant.CITY_CACHE_REDIS, map);
|
||||
redisTemplate.opsForHash().putAll(RedisHttpConstant.CITY_CACHE_REDIS, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, String> all() {
|
||||
String value = redisTemplate.opsForValue().get(RedisConstant.CITY_CACHE_ALL_REDIS);
|
||||
String value = redisTemplate.opsForValue().get(RedisHttpConstant.CITY_CACHE_ALL_REDIS);
|
||||
if(value != null){
|
||||
return JSON.parseObject(value, new TypeReference<LinkedHashMap<Long, String>>(){});
|
||||
}
|
||||
List<Citys> list = this.list();
|
||||
Map<Long, String> map = list.stream().collect(Collectors.toMap(Citys::getId, Citys::getName));
|
||||
redisTemplate.opsForValue().set(RedisConstant.CITY_CACHE_REDIS,JSON.toJSONString(map),30, TimeUnit.DAYS);
|
||||
redisTemplate.opsForValue().set(RedisHttpConstant.CITY_CACHE_REDIS,JSON.toJSONString(map),30, TimeUnit.DAYS);
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -59,7 +58,7 @@ public class CitysServiceImpl extends ServiceImpl<CitysMapper, Citys> implements
|
||||
if(cityId == null || cityId == 0){
|
||||
return null;
|
||||
}
|
||||
Object val = redisTemplate.opsForHash().get(RedisConstant.CITY_CACHE_REDIS, cityId+"");
|
||||
Object val = redisTemplate.opsForHash().get(RedisHttpConstant.CITY_CACHE_REDIS, cityId+"");
|
||||
if(val != null){
|
||||
return String.valueOf(val);
|
||||
}
|
||||
@@ -67,7 +66,7 @@ public class CitysServiceImpl extends ServiceImpl<CitysMapper, Citys> implements
|
||||
if(city == null){
|
||||
return null;
|
||||
}
|
||||
redisTemplate.opsForHash().put(RedisConstant.CITY_CACHE_REDIS, cityId, city.getName());
|
||||
redisTemplate.opsForHash().put(RedisHttpConstant.CITY_CACHE_REDIS, cityId, city.getName());
|
||||
return city.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.constant.RedisConstant;
|
||||
import com.ruoyi.cai.constant.RedisHttpConstant;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.domain.UserGreet;
|
||||
import com.ruoyi.cai.dto.admin.vo.UserGreetAdminVo;
|
||||
@@ -113,13 +113,13 @@ public class UserGreetServiceImpl extends ServiceImpl<UserGreetMapper,UserGreet>
|
||||
}
|
||||
try {
|
||||
lock.lock(3,TimeUnit.SECONDS);
|
||||
String numKey = String.format(RedisConstant.USER_GREET_TOTAL_REDIS, DateUtil.today(), userId);
|
||||
String numKey = String.format(RedisHttpConstant.USER_GREET_TOTAL_REDIS, DateUtil.today(), userId);
|
||||
String val = stringRedisTemplate.opsForValue().get(numKey);
|
||||
Long max = systemConfigManager.getSystemConfigOfLong(SystemConfigEnum.TODAY_GREET_MAX);
|
||||
if(val != null && Long.parseLong(val) > max){
|
||||
throw new ServiceException("您今天打招呼的次数已经用完了");
|
||||
}
|
||||
String sendGreetCount = String.format(RedisConstant.USER_GREET_SEND_TIME_REDIS,userId);
|
||||
String sendGreetCount = String.format(RedisHttpConstant.USER_GREET_SEND_TIME_REDIS,userId);
|
||||
String lastTime = stringRedisTemplate.opsForValue().get(sendGreetCount);
|
||||
if(StringUtils.isNotBlank(lastTime)){
|
||||
Integer inter = systemConfigManager.getSystemConfigOfInt(SystemConfigEnum.GREET_INTERVAL_MIN);
|
||||
|
||||
Reference in New Issue
Block a user