|
|
@@ -4,20 +4,24 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springblade.client.entity.CorpsDesc;
|
|
|
+import org.springblade.client.entity.GoodsDesc;
|
|
|
+import org.springblade.client.entity.StorageDesc;
|
|
|
+import org.springblade.client.entity.StorageType;
|
|
|
import org.springblade.client.feign.ICorpsDescClient;
|
|
|
import org.springblade.client.feign.IGoodsDescClient;
|
|
|
import org.springblade.client.feign.IRedisClient;
|
|
|
import org.springblade.client.feign.IStorageClient;
|
|
|
import org.springblade.client.goods.enums.RedisKey;
|
|
|
-import org.springblade.client.vo.CorpsDescVO;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tenant.annotation.NonDS;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
|
@@ -98,4 +102,61 @@ public class RedisClient implements IRedisClient {
|
|
|
System.out.println("库区:" + redisTemplate.opsForValue().get("storageDesc"));
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R selectRedis(String type) {
|
|
|
+ //redis缓存基础资料数据
|
|
|
+ //用户
|
|
|
+ if (RedisKey.REDIS_USER.equals(type)) {
|
|
|
+ //用户
|
|
|
+ List<User> userList = castToList(redisTemplate.opsForValue().get(type), User.class);
|
|
|
+ return R.data(userList);
|
|
|
+ }
|
|
|
+ //商品
|
|
|
+ if (RedisKey.REDIS_GOODS.equals(type)) {
|
|
|
+ //库区
|
|
|
+ List<GoodsDesc> goodsDescList = castToList(redisTemplate.opsForValue().get(type), GoodsDesc.class);
|
|
|
+ return R.data(goodsDescList);
|
|
|
+ }
|
|
|
+ //客户
|
|
|
+ if (RedisKey.REDIS_CORPS.equals(type)) {
|
|
|
+ //客户
|
|
|
+ List<CorpsDesc> corpsDescList = castToList(redisTemplate.opsForValue().get(type), CorpsDesc.class);
|
|
|
+ return R.data(corpsDescList);
|
|
|
+ }
|
|
|
+ //仓库
|
|
|
+ if (RedisKey.REDIS_STORAGE_TYPE.equals(type)) {
|
|
|
+ //仓库
|
|
|
+ List<StorageType> storageTypeList = castToList(redisTemplate.opsForValue().get(type), StorageType.class);
|
|
|
+ return R.data(storageTypeList);
|
|
|
+ }
|
|
|
+ //库区
|
|
|
+ if (RedisKey.REDIS_STORAGE_DESC.equals(type)) {
|
|
|
+ //库区
|
|
|
+ List<StorageDesc> storageDescList = castToList(redisTemplate.opsForValue().get(type), StorageDesc.class);
|
|
|
+ return R.data(storageDescList);
|
|
|
+ }
|
|
|
+ return R.fail("参数错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将Object转换成List类型
|
|
|
+ *
|
|
|
+ * @param obj Object对象
|
|
|
+ * @param clazz 数据类型
|
|
|
+ * @param <T> 泛型类型
|
|
|
+ * @return List类型
|
|
|
+ */
|
|
|
+ public static <T> List<T> castToList(Object obj, Class<T> clazz) {
|
|
|
+ List<T> resList = new ArrayList<>();
|
|
|
+ // 如果不是List<?>对象,是没有办法转换的
|
|
|
+ if (obj instanceof List<?>) {
|
|
|
+ for (Object o : (List<?>) obj) {
|
|
|
+ // 将对应的元素进行类型转换
|
|
|
+ resList.add(clazz.cast(o));
|
|
|
+ }
|
|
|
+ return resList;
|
|
|
+ }
|
|
|
+ return resList;
|
|
|
+ }
|
|
|
}
|