定时器测试2

pull/2/head
ZhiShuo_Lou 2023-10-29 08:30:32 +08:00
parent 2ffeb09176
commit 1fef9d675d
1 changed files with 6 additions and 7 deletions

View File

@ -1,10 +1,9 @@
package com.ruoyi.mybasic.timer;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.mybasic.common.domain.response.PurseResponse;
import com.ruoyi.mybasic.controller.PurseControllerTwo;
import com.ruoyi.mybasic.service.PurseServiceTwo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -17,7 +16,7 @@ import org.springframework.stereotype.Component;
public class SysUserPurse {
@Autowired
private PurseControllerTwo purseControllerTwo;
private PurseServiceTwo purseServiceTwo;
@Autowired
private RedisService redisService;
@ -35,13 +34,13 @@ public class SysUserPurse {
Long userId = SecurityUtils.getUserId();
//根据用户编号查询用户钱包
R<PurseResponse> purseResponseR = purseControllerTwo.purseObject();
PurseResponse data = purseResponseR.getData();
if (null == data){
PurseResponse purseResponse = purseServiceTwo.purseObject(userId);
if (null == purseResponse){
throw new RuntimeException("查无此用户!");
}
//钱包余额
Integer balanceFee = data.getBalanceFee();
Integer balanceFee = purseResponse.getBalanceFee();
//将余额存入redis
redisService.setCacheObject(userId + PURSE_NAME,balanceFee);
}