Kaynağa Gözat

新增功能:
优化代码

liukx@elab 6 yıl önce
ebeveyn
işleme
39be8e1100

+ 5 - 5
elab-log/src/main/java/com/elab/log/filter/HttpCatCrossFliter.java

@@ -45,12 +45,12 @@ public class HttpCatCrossFliter implements Filter {
         HttpServletRequest request = (HttpServletRequest) req;
         String requestURI = request.getRequestURI();
         String contentType = request.getContentType();
-        String method = request.getMethod();
+//        String method = request.getMethod();
         // 过滤非匹配的拦截请求
-        if (!"GET".equals(method) && !includeContentType(contentType)) {
-            filterChain.doFilter(req, resp);
-            return;
-        }
+//        if (!"GET".equals(method) && !includeContentType(contentType)) {
+////            filterChain.doFilter(req, resp);
+////            return;
+////        }
 
 
         String rootId = request.getHeader(Cat.Context.ROOT);

+ 16 - 3
elab-mongodb/src/main/java/com/elab/mongodb/BaseMongodb.java

@@ -95,12 +95,25 @@ public abstract class BaseMongodb<T> {
      * @throws Exception
      */
     public Long count(T entity) throws Exception {
+
+        return count(entity, getCollectionName());
+    }
+
+    /**
+     * 根据条件查询总数
+     *
+     * @param entity         查询对象
+     * @param collectionName 查询collection名称
+     * @return
+     * @throws Exception
+     */
+    public Long count(T entity, String collectionName) throws Exception {
         Query query = beanForQuery(entity);
         long count = 0;
-        if (getCollectionName() == null) {
-            count = getMongoTemplate().count(query, getEntity());
+        if (collectionName == null) {
+            count = getMongoTemplate().count(query, getEntity(), collectionName);
         } else {
-            count = getMongoTemplate().count(query, getEntity(), getCollectionName());
+            count = getMongoTemplate().count(query, getEntity(), collectionName);
         }
         return count;
     }

+ 2 - 0
elab-spring/src/main/java/com/elab/spring/exception/CommonException.java

@@ -90,6 +90,7 @@ public class CommonException {
     @ResponseBody
     @ResponseStatus(value = HttpStatus.METHOD_NOT_ALLOWED)
     public Object notFondMethod(Exception ex) {
+        logger.info(" 全局notFondMethod异常捕获 .." + ex.getMessage());
         // 将匹配不到方法的异常状态定位404。
         Info info = getInfo(defaultNotFoundError, "not fond");
         return info;
@@ -99,6 +100,7 @@ public class CommonException {
     @ResponseBody
     @ResponseStatus(value = HttpStatus.NOT_FOUND)
     public Object notReadable(Exception ex) {
+        logger.info(" 全局notFondMethod异常捕获 .." + ex.getMessage());
         // 将参数有异常的数据拦截返回
         Info info = getInfo(defaultNotFoundError, "请检查请求数据..");
         return info;