@Override public List<RoomModel> getRoomModel(String tenantId, QueryData queryData) { String sql ="select * from jg_room where delete_tag = 1 and tenant_id =:tenantId ORDER BY id ASC "; Map<String, Object> param = new HashMap<>(); param.put("tenantId", tenantId); if (queryData.hasKey("roomOrientation")){ sql="select * from jg_room where delete_tag = 1 and tenant_id =:tenantId and room_orientation =: roomOrientation ORDER BY id ASC "; param.put("roomOrientation", queryData.getStrValue("roomOrientation")); } return this.sqlSearch(sql,RoomModel.class,param); }这个语法有错误么
时间: 2024-03-17 08:41:50 浏览: 84
这段代码中有一个语法错误,具体来说是在第9行中,分号后面的空格导致了一个语法错误。正确的代码应该是:
```
@Override
public List<RoomModel> getRoomModel(String tenantId, QueryData queryData) {
String sql ="select * from jg_room where delete_tag = 1 and tenant_id =:tenantId ORDER BY id ASC ";
Map<String, Object> param = new HashMap<>();
param.put("tenantId", tenantId);
if (queryData.hasKey("roomOrientation")){
sql="select * from jg_room where delete_tag = 1 and tenant_id =:tenantId and room_orientation =:roomOrientation ORDER BY id ASC "; // 去掉空格
param.put("roomOrientation", queryData.getStrValue("roomOrientation"));
}
return this.sqlSearch(sql, RoomModel.class, param);
}
```
注意到第9行中的 `:roomOrientation` 前面没有空格。这是因为 SQL 语句中的参数占位符和参数名称之间不应该有空格。
阅读全文