企业同步
This commit is contained in:
@@ -63,7 +63,6 @@
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:3.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.2.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.7" level="project" />
|
||||
@@ -90,5 +89,21 @@
|
||||
<orderEntry type="library" name="Maven: com.aliyun:openapiutil:0.1.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.65" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.65" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:3.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.2.6.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.2.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.2.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:5.2.2.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.48.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.48.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.48.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.48.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.48.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.48.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.3.4.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -82,6 +82,10 @@
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-openapi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -8,8 +8,6 @@ package com.cool.store.constants;
|
||||
*/
|
||||
public class CommonConstants {
|
||||
|
||||
public static final String DEFAULT_DB = "coolcollege_intelligent_config";
|
||||
|
||||
public static final String REQUEST_ID = "requestId";
|
||||
|
||||
public static final String ACCESS_TOKEN_KEY = "access_token";
|
||||
@@ -71,6 +69,9 @@ public class CommonConstants {
|
||||
*/
|
||||
public static final String MaxReconsumeTimes = "2";
|
||||
|
||||
public static final String ZERO_STR = "0";
|
||||
public static final String DELETE_DEPT_ID = "-1";
|
||||
public static final String AI_USER_ID = "a100000001";
|
||||
|
||||
public static final int ZERO = 0;
|
||||
public static final int ONE = 1;
|
||||
@@ -94,9 +95,6 @@ public class CommonConstants {
|
||||
public static final int HUNDRED = 100;
|
||||
|
||||
|
||||
|
||||
|
||||
public static final String ZERO_STR = "0";
|
||||
public static final String ONE_STR = "1";
|
||||
public static final String TWO_STR = "2";
|
||||
public static final String THREE_STR = "3";
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.cool.store.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 门店删除状态枚举
|
||||
*/
|
||||
public enum StoreIsDeleteEnum {
|
||||
EFFECTIVE("effective"),//有效
|
||||
|
||||
INVALID("invalid"),//无效
|
||||
|
||||
IGNORED("ignored"), //忽略
|
||||
|
||||
UN_SYNC("unSync"); // 未同步
|
||||
|
||||
private final String value;
|
||||
|
||||
private static final Map<String, StoreIsDeleteEnum> map = Arrays.stream(values()).collect(Collectors.toMap(StoreIsDeleteEnum::getValue, Function.identity()));
|
||||
|
||||
StoreIsDeleteEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static StoreIsDeleteEnum parse(int value) {
|
||||
return map.get(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.cool.store.utils;
|
||||
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* redis工具类
|
||||
*
|
||||
* @author Aaron
|
||||
* @ClassName RedisUtil
|
||||
* @Description redis工具类
|
||||
*/
|
||||
@Repository
|
||||
@Slf4j
|
||||
public class RedisUtil {
|
||||
|
||||
@Resource(name = "customizeTemplate")
|
||||
protected RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
|
||||
public void put(String key, String hashKey, Map<String, Object> value) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
hash.put(key, hashKey, value);
|
||||
}
|
||||
|
||||
public void put(String key, String hashKey, Object value) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
hash.put(key, hashKey, value);
|
||||
}
|
||||
|
||||
|
||||
public Boolean haseHashKey(String key, String hashKey) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
Boolean hase = hash.hasKey(key, hashKey);
|
||||
return hase == null ? Boolean.FALSE : hase;
|
||||
}
|
||||
|
||||
|
||||
public Boolean putIfAbsent(String key, String hashKey, Object value) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
return hash.putIfAbsent(key, hashKey, value);
|
||||
}
|
||||
|
||||
public void putAll(String key, Map<String, Object> value) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
hash.putAll(key, value);
|
||||
}
|
||||
|
||||
public void putAll(String key, Map<String, Object> value, Long time, TimeUnit timeUnit) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
hash.putAll(key, value);
|
||||
redisTemplate.expire(key, time, timeUnit);
|
||||
}
|
||||
|
||||
public void put(String key, Object value, Long time, TimeUnit timeUnit) {
|
||||
redisTemplate.opsForValue().set(key, value, time, timeUnit);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> entries(String key) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
return hash.entries(key);
|
||||
}
|
||||
|
||||
public Object get(String key, String hashKey) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
return hash.get(key, hashKey);
|
||||
}
|
||||
|
||||
public void flushDb() {
|
||||
redisTemplate.getConnectionFactory().getConnection().flushDb();
|
||||
log.info("redis flushDb is ok.");
|
||||
}
|
||||
|
||||
public void delete(String key, Object hashKey) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
hash.delete(key, hashKey);
|
||||
}
|
||||
|
||||
public Collection<Object> multiGet(String key, Collection<String> hashKeys) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
return hash.multiGet(key, hashKeys);
|
||||
}
|
||||
|
||||
public Set<String> keys(String key) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
return hash.keys(key);
|
||||
}
|
||||
|
||||
public Long size(String key) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
return hash.size(key);
|
||||
}
|
||||
|
||||
public Collection<Object> values(String key) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
return hash.values(key);
|
||||
}
|
||||
|
||||
public RedisOperations<String, ?> getOperations() {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
return hash.getOperations();
|
||||
}
|
||||
|
||||
public String hashGetString(String key, String hashKey) {
|
||||
HashOperations<String, String, Object> hash = redisTemplate.opsForHash();
|
||||
Object value = hash.get(key, hashKey);
|
||||
return value == null ? null : String.valueOf(value);
|
||||
}
|
||||
|
||||
public void hashSet(String key, String field, String value) {
|
||||
put(key, field, value);
|
||||
}
|
||||
|
||||
public void lPush(String key, String value) {
|
||||
redisTemplate.opsForList().leftPush(key, value);
|
||||
}
|
||||
|
||||
public String rPop(String key) {
|
||||
return (String)redisTemplate.opsForList().rightPop(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查list是否为空
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Boolean listExists(String key) {
|
||||
return redisTemplate.opsForList().size(key) > CommonConstants.ZERO;
|
||||
}
|
||||
|
||||
/**
|
||||
* set集合add
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public Long setAdd(String key, String value) {
|
||||
return redisTemplate.opsForSet().add(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* set集合校验value是否存在
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public Boolean setIsMember(String key, String value) {
|
||||
return redisTemplate.opsForSet().isMember(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* set集合长度
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Long setSize(String key) {
|
||||
return redisTemplate.opsForSet().size(key);
|
||||
}
|
||||
|
||||
public void delete(String key) {
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user