修改redis配置参数,新增获取账号爬取次数接口
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.yupi.springbootinit.service;
|
||||
|
||||
import com.yupi.springbootinit.model.vo.common.AccountCrawlCount;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/6/16 14:07
|
||||
*/
|
||||
public interface CommonService {
|
||||
AccountCrawlCount getAccountCrawlCount(String accountName);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.yupi.springbootinit.service.impl;
|
||||
|
||||
import com.yupi.springbootinit.common.ErrorCode;
|
||||
import com.yupi.springbootinit.exception.BusinessException;
|
||||
import com.yupi.springbootinit.model.vo.common.AccountCrawlCount;
|
||||
import com.yupi.springbootinit.service.CommonService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/6/16 14:08
|
||||
*/
|
||||
@Service
|
||||
public class CommonServiceImpl implements CommonService {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public AccountCrawlCount getAccountCrawlCount(String accountName) {
|
||||
AccountCrawlCount accountCrawlCount = new AccountCrawlCount();
|
||||
accountCrawlCount.setAccountName(accountName);
|
||||
Object o = redisTemplate.opsForValue().get("tkaccount:" + accountName);
|
||||
if (o != null) {
|
||||
accountCrawlCount.setCount(Integer.valueOf(o.toString()));
|
||||
return accountCrawlCount;
|
||||
}else{
|
||||
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user