各位大佬,如果前端传来key查到多个value,实现类里面要怎么写,现在能查到一个value,如果有多个value就不行了,各位大佬教教小白,谢谢
这是controller
@ResponseBody()
@RequestMapping("get-PersonsNumber.do")
public JSONObject getPersonsNumber(HttpServletRequest request,String attrValue){
List<DiaDispatchingLogsAttr> list = dispLogsService.selectPersonsNumber(attrValue);
JSONObject json = new JSONObject();
json.put("list", list);
return json;
}
}
这是service
List<DiaDispatchingLogsAttr> selectPersonsNumber(String attrValue);
这是实现类
@Override
public List<DiaDispatchingLogsAttr> selectPersonsNumber(String attrValue){
List<DiaDispatchingLogsAttr> result = new ArrayList<>();
HashMap<String, Object> map = new HashMap<>();
try {
map = diaDispatchingLogsAttrMapper.selectPersonsNumber(attrValue);
if(map!=null){
result = new ArrayList(map.values());
}
}catch (Exception e){
e.printStackTrace();
}
return result;
}
}
这是mapper
HashMap<String, Object> selectPersonsNumber(@Param("attrValue") String attrValue);
这是xml
<select id="selectPersonsNumber" parameterType="java.lang.String" resultType="java.util.HashMap">
SELECT DISTINCT a.ATTR_VALUE FROM DIA_DISPATCHING_LOGS_ATTR a where a.ATTR_KEY='contactPhone'
AND a.ATTR_VALUE is not null AND a.LOGS_ID in(SELECT t.LOGS_ID FROM DIA_DISPATCHING_LOGS_ATTR t where
t.ATTR_KEY='reportName' AND t.ATTR_VALUE= '${attrValue}')
</select>
</mapper>
这是数据库查到多个value值