feat: 热力图和咖啡因缓存

This commit is contained in:
zlg
2024-07-11 14:56:31 +08:00
parent c3eb827497
commit 4cc8fec868
31 changed files with 1173 additions and 14 deletions

View File

@@ -31,6 +31,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -371,6 +372,23 @@ public class SchisandraAuthUserController {
}
return Result.ok(JSONObject.parseObject(result));
}
/**
* @description: 获取用户信息
* @param: [userId]
* @return: com.schisandra.auth.common.entity.Result<com.schisandra.auth.application.dto.SchisandraAuthUserDTO>
* @author zlg
* @date: 2024/7/11 9:39
*/
@GetMapping("getUserInfo")
public Result<SchisandraAuthUserDTO> getUserInfo(@RequestParam("userId") Long userId) {
SchisandraAuthUserDTO schisandraAuthUserDTO = SchisandraAuthUserDTOConverter.INSTANCE.convertBOToDTO(schisandraAuthUserDomainService.queryById(userId));
if ( schisandraAuthUserDTO== null) {
return Result.fail("该用户不存在");
}else {
return Result.ok(schisandraAuthUserDTO);
}
}
}

View File

@@ -5,6 +5,9 @@ import com.schisandra.auth.common.entity.Result;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import me.zhyd.oauth.model.AuthUser;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import java.util.HashMap;
@@ -61,6 +64,7 @@ public interface SchisandraAuthUserDomainService {
* @author schisandra
* @date 2024/3/21 23:14
*/
@CachePut(value = "userInfo", key = "#schisandraAuthUserBO.id")
Object update(SchisandraAuthUserBO schisandraAuthUserBO);
/**
@@ -70,6 +74,7 @@ public interface SchisandraAuthUserDomainService {
* @author: landaiqing
* @date: 2024/5/26 17:27
*/
Result insertAuthUserByOauth(AuthUser data, String type);
/**
@@ -79,7 +84,8 @@ public interface SchisandraAuthUserDomainService {
* @author: landaiqing
* @date: 2024/5/26 17:27
*/
SchisandraAuthUserBO queryById(SchisandraAuthUserBO schisandraAuthUserBO);
@Cacheable(value = "userInfo", key = "#userId")
SchisandraAuthUserBO queryById(Long userId);
/**
* @param schisandraAuthUserBO
@@ -95,6 +101,7 @@ public interface SchisandraAuthUserDomainService {
* @description 删除用户(物理)
* @author msz
*/
@CacheEvict(value = "userInfo",key = "id")
Object deleteById(Long id);
SchisandraAuthUser queryByPhone(String phone);

View File

@@ -167,15 +167,15 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
/**
* @param schisandraAuthUserBO
* @param Long
* @return
* @description 查询用户信息
* @author msz
* @date 2024/4/3 22:10
*/
@Override
public SchisandraAuthUserBO queryById(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = schisandraAuthUserService.queryById(schisandraAuthUserBO.getId());
public SchisandraAuthUserBO queryById(Long userId) {
SchisandraAuthUser schisandraAuthUser = schisandraAuthUserService.queryById(userId);
SchisandraAuthUserBO schisandraAuthUserBO1 = SchisandraAuthUserBOConverter.INSTANCE.convertEntityToBO(schisandraAuthUser);
return schisandraAuthUserBO1;
}

View File

@@ -3,6 +3,7 @@ package com.schisandra.auth;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@MapperScan("com.schisandra.**.dao")
@EnableFeignClients(basePackages = "com.schisandra")
@EnableTransactionManagement
@EnableCaching
public class AuthApplication {
public static void main(String[] args) {
SpringApplication.run(AuthApplication.class);

View File

@@ -27,6 +27,11 @@ spring:
enabled: true
config:
enabled: true
#caffeine缓存
cache:
type: caffeine
caffeine:
spec: maximumSize=10000,expireAfterAccess=60s
# redis配置
redis:
# Redis数据库索引默认为0
@@ -108,3 +113,4 @@ rocketmq:
producer:
group: schisandra-cloud-storage-auth-group
send-message-timeout: 6000