feature: 收藏功能.

This commit is contained in:
lijiahang
2023-09-05 11:50:53 +08:00
parent fb42e31f6e
commit 8035396995
15 changed files with 206 additions and 46 deletions

View File

@@ -1,6 +1,7 @@
package com.orion.ops.framework.common.entity;
import com.orion.lang.define.wrapper.IPageRequest;
import com.orion.ops.framework.common.valid.group.Page;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
@@ -15,11 +16,11 @@ import org.hibernate.validator.constraints.Range;
@Data
public class PageRequest implements IPageRequest {
@Range(min = 1, max = 10000, groups = IPageRequest.class)
@Range(min = 1, max = 10000, groups = Page.class)
@Schema(description = "页码")
private int page;
@Range(min = 1, max = 100, groups = IPageRequest.class)
@Range(min = 1, max = 100, groups = Page.class)
@Schema(description = "大小")
private int limit;

View File

@@ -0,0 +1,11 @@
package com.orion.ops.framework.common.valid.group;
/**
* 分页验证分组
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/9/1 19:13
*/
public interface Id {
}

View File

@@ -0,0 +1,11 @@
package com.orion.ops.framework.common.valid.group;
/**
* 分页验证分组
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/9/1 19:13
*/
public interface Page {
}

View File

@@ -3,6 +3,7 @@ package com.orion.ops.framework.redis.core.utils;
import com.alibaba.fastjson.JSON;
import com.orion.lang.define.cache.CacheKeyDefine;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.collect.Lists;
import com.orion.lang.utils.io.Streams;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.RedisCallback;
@@ -10,8 +11,10 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ScanOptions;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
/**
* redis 工具类
@@ -132,6 +135,50 @@ public class RedisUtils {
}
}
/**
* 查询 list 区间
*
* @param key key
* @return list
*/
public static List<String> listRange(String key) {
// 查询列表
List<String> elements = redisTemplate.opsForList().range(key, 0, -1);
if (elements == null) {
return Lists.newList();
}
return elements;
}
/**
* 查询 list 区间
*
* @param key key
* @param mapper mapper
* @param <T> T
* @return list
*/
public static <T> List<T> listRange(String key, Function<String, T> mapper) {
// 查询列表
List<String> elements = redisTemplate.opsForList().range(key, 0, -1);
if (elements == null) {
return Lists.newList();
}
return Lists.map(elements, mapper);
}
/**
* list 添加元素
*
* @param key key
* @param list list
* @param mapper mapper
* @param <T> T
*/
public static <T> void listPushAll(String key, List<T> list, Function<T, String> mapper) {
redisTemplate.opsForList().rightPushAll(key, Lists.map(list, mapper));
}
/**
* 设置过期时间
*