Browse Source

方法传参不规范

shiqian 4 năm trước cách đây
mục cha
commit
8a8c02e8a6

+ 1 - 1
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/JSONArrayUtils.java

@@ -10,7 +10,7 @@ import com.boman.common.core.utils.obj.ObjectUtils;
 public class JSONArrayUtils {
     
     public static long[] jsonArrayToLongArray(JSONArray jsonArray){
-        ObjectUtils.requireNonNull(jsonArray);
+        ObjectUtils.requireNonNull(jsonArray, "jsonArrayToLongArray jsonArray is empty");
         long[] result = new long[jsonArray.size()];
         for (int i = 0; i < jsonArray.size(); i++) {
             result[i] = jsonArray.getLong(i);

+ 2 - 2
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/collection/CollectionUtils.java

@@ -13,7 +13,7 @@ import java.util.stream.Collectors;
 public class CollectionUtils {
 
     public static Long[] listToArray(List<Long> longList){
-        ObjectUtils.requireNonNull(longList);
+        ObjectUtils.requireNonNull(longList, "listToArray input data is empty");
         return longList.toArray(new Long[0]);
     }
 
@@ -30,7 +30,7 @@ public class CollectionUtils {
         return buffer.toString();
     }
 
-    public static <T> List<T> distinct(List<T> one, List<T> another) {
+    public static <T> List<T> addAllDistinct(List<T> one, List<T> another) {
         one.addAll(another);
         return one.stream().distinct().collect(Collectors.toList());
     }

+ 22 - 22
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/obj/ObjectUtils.java

@@ -20,16 +20,16 @@ public class ObjectUtils {
     private static final String NULL = "null";
     private static final String UNDEFINED = "undefined";
 
-    public static  <T> Collection<T> requireNonNull(Collection<T> input, String... errorMsg){
+    public static  <T> Collection<T> requireNonNull(Collection<T> input, String errorMsg){
         if (null == input || input.size() == 0) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
         return input;
     }
 
-    public static  <T> List<T> requireNonNull(List<T> input, String... errorMsg){
+    public static  <T> List<T> requireNonNull(List<T> input, String errorMsg){
         if (null == input || input.size() == 0) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
         return input;
     }
@@ -42,40 +42,40 @@ public class ObjectUtils {
         return !isEmpty(input);
     }
 
-    public static long[] requireNonNull(long[] input, String... errorMsg){
+    public static long[] requireNonNull(long[] input, String errorMsg){
         if (ArrayUtils.isEmpty(input)) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
 
         return input;
     }
 
 
-    public static Long[] requireNonNull(Long[] input, String... errorMsg){
+    public static Long[] requireNonNull(Long[] input, String errorMsg){
         if (ArrayUtils.isEmpty(input)) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
 
         return input;
     }
 
-    public static Boolean requireNonNull(Boolean input, String... errorMsg) {
+    public static Boolean requireNonNull(Boolean input, String errorMsg) {
         if (input == null) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
         return input;
     }
 
-    public static <T> T requireNonNull(T input, String... errorMsg) {
+    public static <T> T requireNonNull(T input, String errorMsg) {
         if (input == null) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
         return input;
     }
 
-    public static Integer requireNonNull(Integer input, String... errorMsg) {
+    public static Integer requireNonNull(Integer input, String errorMsg) {
         if (input == null || input < 0) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
         return input;
     }
@@ -97,24 +97,24 @@ public class ObjectUtils {
         return !isEmpty(input);
     }
 
-    public static String requireNonNull(String input, String... errorMsg) {
+    public static String requireNonNull(String input, String errorMsg) {
         if (input == null || input.isEmpty() || NULL.equalsIgnoreCase(input) || UNDEFINED.equalsIgnoreCase(input)) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
         return input;
     }
 
-    public static int requireNonNull(int input, String... errorMsg) {
+    public static int requireNonNull(int input, String errorMsg) {
         if (input <= 0) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
         return input;
     }
 
 
-    public static JSONObject requireNonNull(JSONObject input, String... errorMsg) {
+    public static JSONObject requireNonNull(JSONObject input, String errorMsg) {
         if (input == null || input.isEmpty()) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
         return input;
     }
@@ -187,9 +187,9 @@ public class ObjectUtils {
         return !isEmpty(input);
     }
 
-    public static JSONArray requireNonNull(JSONArray input, String... errorMsg) {
+    public static JSONArray requireNonNull(JSONArray input, String errorMsg) {
         if (input == null || input.isEmpty()) {
-            throw new IllegalArgumentException(errorMsg[0]);
+            throw new IllegalArgumentException(errorMsg);
         }
         return input;
     }

+ 2 - 2
boman-modules/boman-gen/src/main/java/com/boman/gen/service/LoadTableServerImpl.java

@@ -47,12 +47,12 @@ public class LoadTableServerImpl implements ILoadTableServer{
     @Override
     public AjaxResult loadTable(GenTable genTable) {
         List<GenTable> tableList = genTableService.selectGenTableList(genTable);
-        requireNonNull(tableList);
+        requireNonNull(tableList, "tableList is empty");
 
         // load table and tableColumn
         List<Long> tableIdList = tableList.stream().map(GenTable::getId).collect(Collectors.toList());
         List<GenTableColumn> genTableColumns = genTableColumnService.listByTableIdList(tableIdList);
-        requireNonNull(genTableColumns);
+        requireNonNull(genTableColumns, "genTableColumns is empty");
         packTableAndInsertToRedis(tableList, genTableColumns);
 
         List<GenTableRelation> relationList = genTableRelationService.selectGenTableRelationList(new GenTableRelation());

+ 1 - 1
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysRoleMenuServiceImpl.java

@@ -75,7 +75,7 @@ public class SysRoleMenuServiceImpl implements ISysRoleMenuService{
             childList = buildBtnByHead(head, childList);
             List<Long> childIdList = map(childList, SysMenu::getId);
             List<SysRoleMenu> roleMenuList = buildRoleMenu(roleId, childIdList);
-            List<Long> distinct = CollectionUtils.distinct(childIdList, map(originChildList, SysMenu::getId));
+            List<Long> distinct = CollectionUtils.addAllDistinct(childIdList, map(originChildList, SysMenu::getId));
             try {
                 // 先删除,再添加,防止联合索引报错
                 deleteByRoleIdList(Collections.singletonList(roleId), distinct);

+ 6 - 6
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -204,7 +204,7 @@ public class TableServiceCmdService {
     public AjaxResult objectLogicDelete(FormDataDto dto) {
         requireNonNull(dto.getTable(), "tableName = [" + dto.getTable() + "] 此表不存在");
         Long[] idArr = CollectionUtils.listToArray(dto.getIdList());
-        requireNonNull(idArr);
+        requireNonNull(idArr, "objectLogicDelete idArr is empty");
 
         // 拿到pkName
         GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
@@ -517,7 +517,7 @@ public class TableServiceCmdService {
         List<Long> idList = map(commitData, jsonObject -> jsonObject.getLong(FormDataConstant.ID));
 
         List<JSONObject> beforeList = selectService.selectByIdList(tableName, pkName, idList, Lists.newArrayList(pkName, STATUS));
-        requireNonNull(beforeList);
+        requireNonNull(beforeList, "beforeList is empty");
 
         for (JSONObject commitDatum : commitData) {
             String dbStatus = getStatusFromFormData(commitDatum, beforeList);
@@ -581,8 +581,8 @@ public class TableServiceCmdService {
      * @return 结果
      */
     public List<JSONObject> isCustomized(String tableName, List<JSONObject> result, String action) {
-        requireNonNull(tableName);
-        requireNonNull(action);
+        requireNonNull(tableName, "tableName is empty");
+        requireNonNull(action, "action is empty");
         if (result != null && result.size() > 0) {
             //获取到服务名称
             String triggerName = getTriggerName(tableName, action);
@@ -603,7 +603,7 @@ public class TableServiceCmdService {
      */
     private String getTriggerName(String tableName, String action) {
         GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, tableName);
-        requireNonNull(genTable);
+        requireNonNull(genTable, "genTable empty");
         if (action.equals(TriggerActionConstant.ACTION_CREATE)) {
             return genTable.getTriggerCreate();
         } else if (action.equals(TriggerActionConstant.ACTION_RETRIEVE)) {
@@ -627,7 +627,7 @@ public class TableServiceCmdService {
      */
     public GenTable getTableFromRedisByTableName(String redisKeyPrefix, String tableName) {
         tableName = tableName.trim().toLowerCase();
-        String key = requireNonNull(redisKeyPrefix) + requireNonNull(tableName);
+        String key = requireNonNull(redisKeyPrefix, "redisKeyPrefix is empty") + requireNonNull(tableName, "tableName is empty");
         GenTable genTable = redisService.getCacheObject(key);
         if (ObjectUtils.isEmpty(genTable)) {
             genTable = remoteGenTableService.getByTableName(tableName);

+ 4 - 6
boman-web-core/src/main/java/com/boman/web/core/service/select/BaseSelectServiceImpl.java

@@ -44,16 +44,14 @@ public class BaseSelectServiceImpl implements IBaseSelectService {
      * @param condition     原始查询条件
      * @param packCondition 封装的查询条件
      * @param showData      前台需要查询的列
-     * @param orderBy       orderBy
-     * @param limit         分页
-     * @param offset        分页
+     * @param dto           orderBy limit offset
      * @return java.util.List<com.alibaba.fastjson.JSONObject>
      */
     @Override
     public List<JSONObject> selectByCondition(String tableName, JSONObject condition, JSONObject packCondition, JSONArray showData, FormDataDto dto) {
         requireNonNull(tableName, "表名为空");
         requireNonNull(showData, "表: [" + tableName + "] , 过滤了可展示字段,一个展示字段都没有,还查个鬼啊");
-        String orderBy = requireNonNull(dto.getOrderBy());
+        String orderBy = requireNonNull(dto.getOrderBy(), "order by is empty");
         return mapper.selectByCondition(tableName, condition, packCondition, showData, orderBy, dto.getLimit(), dto.getOffset());
     }
 
@@ -122,7 +120,7 @@ public class BaseSelectServiceImpl implements IBaseSelectService {
     public JSONObject selectById(String tableName, String pkName, Long id) {
         requireNonNull(tableName, "表名为空");
         requireNonNull(pkName, "主键名称为空");;
-        requireNonNull(id);
+        requireNonNull(id, "selectById id is empty");
         return mapper.selectById(tableName, pkName, id);
     }
 
@@ -139,7 +137,7 @@ public class BaseSelectServiceImpl implements IBaseSelectService {
     public List<JSONObject> selectByIdList(String tableName, String pkName, List<Long> idList, List<String> showData) {
         requireNonNull(tableName, "表名为空");
         requireNonNull(pkName, "主键名称为空");;
-        requireNonNull(idList);
+        requireNonNull(idList, "selectByIdList idList is empty");
 
         return mapper.selectByIdList(tableName, pkName, idList, showData);
     }

+ 1 - 1
boman-web-core/src/main/java/com/boman/web/core/service/update/BaseUpdateServiceImpl.java

@@ -54,7 +54,7 @@ public class BaseUpdateServiceImpl implements IBaseUpdateService {
     }
 
     private JSONObject escapeByQueryType(List<GenTableColumn> columns, JSONObject commitData) {
-        requireNonNull(columns);
+        requireNonNull(columns, "columns is empty");
         JSONObject result = new JSONObject(columns.size());
         for (Map.Entry<String, Object> entry : commitData.entrySet()) {
             String key = entry.getKey();