代码优化

v1.4.1
Parker 4 years ago
parent 5c68f4c998
commit 42103319e0

@ -64,7 +64,8 @@ public final class HumpUtil {
public static String humpToUnderline(String para) { public static String humpToUnderline(String para) {
StringBuilder sb = new StringBuilder(para); StringBuilder sb = new StringBuilder(para);
int temp = 0;//定位 //定位
int temp = 0;
if (!para.contains(UNDERLINE)) { if (!para.contains(UNDERLINE)) {
for (int i = 0; i < para.length(); i++) { for (int i = 0; i < para.length(); i++) {
if (Character.isUpperCase(para.charAt(i))) { if (Character.isUpperCase(para.charAt(i))) {

@ -1,7 +1,5 @@
package org.opsli.common.utils; package org.opsli.common.utils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;

@ -15,6 +15,8 @@
*/ */
package org.opsli.core.cache.pushsub.handler; package org.opsli.core.cache.pushsub.handler;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.opsli.api.wrapper.system.dict.DictWrapper; import org.opsli.api.wrapper.system.dict.DictWrapper;
@ -29,6 +31,7 @@ import org.opsli.plugins.cache.EhCachePlugin;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.Collection; import java.util.Collection;
import java.util.List;
/** /**
* @BelongsProject: opsli-boot * @BelongsProject: opsli-boot
@ -41,7 +44,7 @@ import java.util.Collection;
public class DictHandler implements RedisPushSubHandler{ public class DictHandler implements RedisPushSubHandler{
@Autowired @Autowired
EhCachePlugin ehCachePlugin; private EhCachePlugin ehCachePlugin;
@Override @Override
public PushSubType getType() { public PushSubType getType() {
@ -54,15 +57,12 @@ public class DictHandler implements RedisPushSubHandler{
CacheType type = CacheType.valueOf((String) msgJson.get(MsgArgsType.DICT_TYPE.toString())); CacheType type = CacheType.valueOf((String) msgJson.get(MsgArgsType.DICT_TYPE.toString()));
if(DictModelType.COLLECTION == dictModelType){ if(DictModelType.COLLECTION == dictModelType){
Collection<Object> dicts = (Collection<Object>) msgJson.get(MsgArgsType.DICT_MODELS.toString()); Object dictListObj = msgJson.get(MsgArgsType.DICT_MODELS.toString());
for (Object dictObj : dicts) { List<DictWrapper> dictWrappers = Convert.toList(DictWrapper.class, dictListObj);
JSONObject jsonObject = msgJson.getJSONObject(MsgArgsType.DICT_MODEL.toString()); if(CollUtil.isNotEmpty(dictWrappers)){
if(jsonObject == null){ for (DictWrapper dictWrapper : dictWrappers) {
continue; this.handler(dictWrapper, type);
} }
DictWrapper dictWrapperModel = jsonObject.toJavaObject(DictWrapper.class);
this.handler(dictWrapperModel, type);
} }
} else if(DictModelType.OBJECT == dictModelType){ } else if(DictModelType.OBJECT == dictModelType){
JSONObject jsonObject = msgJson.getJSONObject(MsgArgsType.DICT_MODEL.toString()); JSONObject jsonObject = msgJson.getJSONObject(MsgArgsType.DICT_MODEL.toString());

@ -37,7 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public class EdenDataHandler implements RedisPushSubHandler{ public class EdenDataHandler implements RedisPushSubHandler{
@Autowired @Autowired
EhCachePlugin ehCachePlugin; private EhCachePlugin ehCachePlugin;
@Override @Override
public PushSubType getType() { public PushSubType getType() {

@ -36,7 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public class HotDataHandler implements RedisPushSubHandler{ public class HotDataHandler implements RedisPushSubHandler{
@Autowired @Autowired
EhCachePlugin ehCachePlugin; private EhCachePlugin ehCachePlugin;
@Override @Override
public PushSubType getType() { public PushSubType getType() {

@ -37,7 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public class MenuHandler implements RedisPushSubHandler{ public class MenuHandler implements RedisPushSubHandler{
@Autowired @Autowired
EhCachePlugin ehCachePlugin; private EhCachePlugin ehCachePlugin;
@Override @Override
public PushSubType getType() { public PushSubType getType() {

@ -38,7 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public class OrgHandler implements RedisPushSubHandler{ public class OrgHandler implements RedisPushSubHandler{
@Autowired @Autowired
EhCachePlugin ehCachePlugin; private EhCachePlugin ehCachePlugin;
@Override @Override
public PushSubType getType() { public PushSubType getType() {

@ -38,7 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public class TenantHandler implements RedisPushSubHandler{ public class TenantHandler implements RedisPushSubHandler{
@Autowired @Autowired
EhCachePlugin ehCachePlugin; private EhCachePlugin ehCachePlugin;
@Override @Override
public PushSubType getType() { public PushSubType getType() {

@ -39,7 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public class UserHandler implements RedisPushSubHandler{ public class UserHandler implements RedisPushSubHandler{
@Autowired @Autowired
EhCachePlugin ehCachePlugin; private EhCachePlugin ehCachePlugin;
@Override @Override
public PushSubType getType() { public PushSubType getType() {

@ -214,9 +214,9 @@ public class GlobalExceptionHandler {
//log.error("数据异常:{}",e.getMessage(),e); //log.error("数据异常:{}",e.getMessage(),e);
// 默认值异常 // 默认值异常
if(StringUtils.contains(e.getMessage(),SQL_EXCEPTION)){ if(StringUtils.contains(e.getMessage(),SQL_EXCEPTION)){
String Field = e.getMessage().replaceAll("Field '","") String field = e.getMessage().replaceAll("Field '","")
.replaceAll("' doesn't have a default value",""); .replaceAll("' doesn't have a default value","");
String msg = StrFormatter.format(CoreMsg.SQL_EXCEPTION_NOT_HAVE_DEFAULT_VALUE.getMessage(), Field); String msg = StrFormatter.format(CoreMsg.SQL_EXCEPTION_NOT_HAVE_DEFAULT_VALUE.getMessage(), field);
return ResultVo.error(CoreMsg.SQL_EXCEPTION_NOT_HAVE_DEFAULT_VALUE.getCode(), msg); return ResultVo.error(CoreMsg.SQL_EXCEPTION_NOT_HAVE_DEFAULT_VALUE.getCode(), msg);
} }
String msg = StrFormatter.format(CoreMsg.SQL_EXCEPTION_UNKNOWN.getMessage(), e.getMessage()); String msg = StrFormatter.format(CoreMsg.SQL_EXCEPTION_UNKNOWN.getMessage(), e.getMessage());

@ -38,7 +38,7 @@ public class WafFilter implements Filter {
@Override @Override
public void init(FilterConfig config) throws ServletException { public void init(FilterConfig config) {
} }
@Override @Override

@ -110,7 +110,7 @@ public class WafHttpServletRequestWrapper extends HttpServletRequestWrapper {
} }
@Override @Override
public int read() throws IOException { public int read() {
return bis.read(); return bis.read();
} }
}; };

@ -16,6 +16,7 @@
package org.opsli.plugins.redis.lock; package org.opsli.plugins.redis.lock;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.opsli.plugins.redis.RedisLockPlugins; import org.opsli.plugins.redis.RedisLockPlugins;
import org.opsli.plugins.redis.RedisPlugin; import org.opsli.plugins.redis.RedisPlugin;
@ -25,7 +26,6 @@ import org.springframework.stereotype.Service;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* @BelongsProject: opsli-boot * @BelongsProject: opsli-boot
@ -66,7 +66,7 @@ public class RedisLockImpl implements RedisLockPlugins {
@Override @Override
public RedisLock tryLock(RedisLock redisLock) { public RedisLock tryLock(RedisLock redisLock) {
// 锁凭证 // 锁凭证
String identifier = UUID.randomUUID().toString().replaceAll("-",""); String identifier = IdUtil.simpleUUID();
redisLock = this.tryLock(redisLock,identifier); redisLock = this.tryLock(redisLock,identifier);
if(redisLock != null){ if(redisLock != null){
log.info(this.getInfo("分布式锁 - 开启",redisLock)); log.info(this.getInfo("分布式锁 - 开启",redisLock));

@ -1,7 +1,6 @@
package org.opsli.plugins.redis.pushsub.receiver; package org.opsli.plugins.redis.pushsub.receiver;
import com.alibaba.fastjson.JSONObject;
/** /**
* @BelongsProject: opsli-boot * @BelongsProject: opsli-boot
@ -13,7 +12,7 @@ import com.alibaba.fastjson.JSONObject;
public abstract class BaseReceiver { public abstract class BaseReceiver {
public static final String BASE_CHANNEL = "listener:msg:"; public static final String BASE_CHANNEL = "listener:msg:";
private String channel; private final String channel;
public BaseReceiver(String channel){ public BaseReceiver(String channel){
this.channel = BASE_CHANNEL+channel; this.channel = BASE_CHANNEL+channel;

Loading…
Cancel
Save