数据格式异常时status码设置为400,服务异常时status码设置为500,并细化服务异常业务状态码

This commit is contained in:
zhangdongxu
2018-08-03 18:08:46 +08:00
parent 4a353a3975
commit 0a10522bae
11 changed files with 498 additions and 263 deletions

View File

@@ -4,6 +4,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.ServiceRuntimeException;
import com.nis.web.service.SpringContextHolder;
public class BaseRedisDao {
@@ -43,7 +45,7 @@ public class BaseRedisDao {
}
return hasKey;
} else {
throw new RuntimeException("后台错误:" + index + "号redis库中判断" + key + "是否存在时失败,失败原因:redisTemplate为null请联系开发人员");
throw new ServiceRuntimeException("" + index + "号redis库中判断" + key + "是否存在时失败,失败原因:redisTemplate为null请联系开发人员",RestBusinessCode.RedisTemplateIsNull.getValue());
}
}
@@ -60,7 +62,7 @@ public class BaseRedisDao {
Long id = redisTemplate.boundValueOps(key.toUpperCase()).increment(1l);
return id;
} else {
throw new RuntimeException("后台错误:" + index + "号redis库中获取" + key + "的自增长值时失败,失败原因:redisTemplate为null请联系开发人员");
throw new ServiceRuntimeException("" + index + "号redis库中获取" + key + "的自增长值时失败,失败原因:redisTemplate为null请联系开发人员",RestBusinessCode.RedisTemplateIsNull.getValue());
}
}
@@ -70,7 +72,7 @@ public class BaseRedisDao {
redisTemplate.setEnableTransactionSupport(false);
return redisTemplate.opsForValue().get(key);
} else {
throw new RuntimeException("后台错误:" + index + "号redis库中获取" + key + "的值时失败,失败原因:redisTemplate为null请联系开发人员");
throw new ServiceRuntimeException("" + index + "号redis库中获取" + key + "的值时失败,失败原因:redisTemplate为null请联系开发人员",RestBusinessCode.RedisTemplateIsNull.getValue());
}
}