MCPcopy Create free account
hub / github.com/LisenCoding/cangku / checkMap

Method checkMap

boot/src/main/java/com/utils/CommonUtil.java:32–51  ·  view source on GitHub ↗

检查map参数并添加缺失参数 @param params @return

(Map<String, Object> params)

Source from the content-addressed store, hash-verified

30 * @return
31 */
32 public static void checkMap(Map<String, Object> params) {
33 boolean page=true,limit=true,sort=true,order=true;
34 Iterator<Map.Entry<String, Object>> iter = params.entrySet().iterator();
35 while (iter.hasNext()) {
36 Map.Entry<String, Object> info = iter.next();
37 Object key = info.getKey();
38 Object value = info.getValue();
39 if(value==null || "".equals(value) || "null".equals(value)){
40 iter.remove();
41 }else if("page".equals(key)){page=false;
42 }else if("limit".equals(key)){limit=false;
43 }else if("sort".equals(key)){sort=false;
44 }else if("order".equals(key)){order=false;
45 }
46 }
47 if(page){params.put("page","1");}
48 if(limit){params.put("limit","10");}
49 if(sort){params.put("sort","id");}
50 if(order){params.put("order","desc");}
51 }
52}

Callers 15

pageMethod · 0.95
gexingtuijianMethod · 0.95
listMethod · 0.95
pageMethod · 0.95
listMethod · 0.95
pageMethod · 0.95
listMethod · 0.95
pageMethod · 0.95
listMethod · 0.95
pageMethod · 0.95
listMethod · 0.95
pageMethod · 0.95

Calls 2

putMethod · 0.80
getValueMethod · 0.45

Tested by

no test coverage detected