MyBatis 查询集合中的数据

dao 


List<KdTaskEntity> queryByIds(Long[] idslist);

xml

<select id="queryByIds" resultType="io.renren.modules.generator.entity.KdTaskEntity">
select * from kd_task where id in 
<foreach item="taskId" collection="array" open="(" separator="," close=")">
#{taskId}
</foreach> 
</select>

control

	@RequestMapping("/queryAllByIds")	
	public R queryAllByIds(@RequestBody Long[] ids) {
	
		Collection<KdTaskEntity> taskList = kdTaskService.listByIds(Arrays.asList(ids));
		return R.ok().put("List", taskList);

	}

js

 getSameDataList_post() {
      //debugger;;
      this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl(
          "/generator/kdtask/queryAllByIds"
        ),      
        method: "post",
        data: this.$http.adornData(this.taskIdsArray, false)
        // params: this.$http.adornParams({
        //   // ids: this.taskIdsArray,
        //   data: this.$http.adornData(this.taskIdsArray, false)
        // }),
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.List;         
        } else {
          this.totalPage = 0;
        }
        this.dataListLoading = false;
      });
    },

  

原文地址:https://www.cnblogs.com/dayspring/p/13954553.html