今天看 MyBatis-Plus 看到有一句话不明白:
不支持以及不赞成在 RPC 调用中把 Wrapper 进行传输
wrapper 很重
传输 wrapper 可以类比为你的 controller 用 map 接收值(开发一时爽,维护火葬场)
1、不理解 传输wrapper 是什么东西
2、为什么用 map 接收 json 会出问题
3、我这样写有什么隐患吗
@GetMapping
public static Map<String, String> getList() {
Map<String, String> map = new ConcurrentHashMap<>();
map.put("CDN", createLine("yesno", "CDN网站","").toString());
map.put("模块", createLine("dropdown", "","php,iis").toString());
map.put("web配额", createLine("text", "MB","").toString());
return map;
}
/**
* 用于构建 “Value”
*/
private static List<String> createLine(String type, String description, String options) {
List<String> ansList = new ArrayList<>();
if (!type.isEmpty()) ansList.add("Type = " + type);
if (!description.isEmpty()) ansList.add("Description = " + description);
if (!options.isEmpty()) ansList.add("Options = " + options);
return ansList;
}
输出结果如下:
{
"连接数": "[Type = text]",
"FTP": "[Type = yesno, Description = 是否允许ftp]",
"附加参数": "[Type = text]"
}