【六袆-Java】Mybatis根据字段批量查询;Mybatis根据List批量查询_xml

 敲代码不疲劳~

 

1.Controller层 

@ApiOperation("查询品种")
@GetMapping("/findCropById")
public ResponseResult findCropById(Integer cropId){
List<Map<String,Object>> list = taskService.findByCropId(cropId);
return new ResponseResult(list);
}

 

2.Service层

public  List<Map<String, Object>> findByCropId(Integer cropId) {
return taskMapper.findByCropId(cropId);
}

 

3.XML映射

 

@Select("select * from crop_varieties where crop_id=#{cropId}")
List<Map<String, Object>> findByCropId(@Param("cropId")Integer cropId);