MyBatis如何进行双重foreach循环

网友投稿 1172 2022-11-01

MyBatis如何进行双重foreach循环

MyBatis如何进行双重foreach循环

目录进行双重foreach循环使用场景mybatis foreach循环,传入多个参数上代码

进行双重foreach循环

mapname是一个Map> 对象

#{key1},

#{key2},

#{value2}

使用场景

比如说一个付款人下面对应的运单的金额,那么key1就是付款人编号,key2是运单编号,value2是分摊的金额

mybatis foreach循环,传入多个参数

上代码

controller:

@RequestMapping(value = "/findPage", method = RequestMethod.POST)

@ResponseBody

public Object findPage(@RequestParam(required=false) String jobCategory,@RequestParam(required=false) String ids,@RequestParam(required=false) String cities) {

try {

List listJob = new ArrayList();

List listIds = new ArrayList();

List listCities = new ArrayList();

//按照城市名称和工种查询

if(StringUtils.isNotBlank(jobCategory) && StringUtils.isNotBlank(cities)){

String[] temp = jobCategory.split(",");

String[] cityTemp = cities.split(",");

for(int i=0;i

listJob.add(Integer.valueOf(temp[i]));

}

for(int i=0;i

listCities.add(cityTemp[i]);

}

List list = jobService.findPage(listJob, listIds, listCities);

return new ExtGridReturn(list.size(), list);

}

//按照工种查询

if(StringUtils.isNotBlank(jobCategory)){

String[] temp = jobCategory.split(",");

for(int i=0;i

listJob.add(Integer.valueOf(temp[i]));

}

}

//按照职位名称查询

if(StringUtils.isNotBlank(ids)){

String[] temp = ids.split(",");

for(int i=0;i

listIds.add(Integer.valueOf(temp[i]));

}

}

//按照城市查询

if(StringUtils.isNotBlank(cities)){

String[] temp = cities.split(",");

for(int i=0;i

listCities.add(temp[i]);

}

}

List list = jobService.findPage(listJob, listIds, listCities);

JJMdkjNsafreturn new ExtGridReturn(list.size(), list);

} catch (Exception e) {

LOGGER.error("分页获取信息出错", e);

return new ExceptionReturn(e);

}

}

mapper

/**

* 描述:根据工种查询列表

* @param jobCategorys

* @return

*/

List findPage(@Param("jobCategorys") List jobCategorys,@Param("ids") List ids,@Param("workPlace") List workPlace);

xml

JJMdkjNsaf

select n.ID id,

n.NAME name,

n.WORKPLACE workPlace,

n.JOBCATEGORY jobCategory,

n.SALARY salary,

n.RESPONSIBILITIES responsibilities,

n.REQUIREMENTS requirements,

n.ISHOT isHot,

n.UPDATEDATE updateDate,

n.UPDATEUSER updateUser,

u.real_name updateName

from websites_job n

left join base_users u on n.updateUser = u.account

or n.jobCategory in

#{itJJMdkjNsafem}

or n.id in

#{item}

or n.WORKPLACE in

#{item}

order by n.ISHOT,n.ID desc

listJob.add(Integer.valueOf(temp[i]));

}

for(int i=0;i

listCities.add(cityTemp[i]);

}

List list = jobService.findPage(listJob, listIds, listCities);

return new ExtGridReturn(list.size(), list);

}

//按照工种查询

if(StringUtils.isNotBlank(jobCategory)){

String[] temp = jobCategory.split(",");

for(int i=0;i

listJob.add(Integer.valueOf(temp[i]));

}

}

//按照职位名称查询

if(StringUtils.isNotBlank(ids)){

String[] temp = ids.split(",");

for(int i=0;i

listIds.add(Integer.valueOf(temp[i]));

}

}

//按照城市查询

if(StringUtils.isNotBlank(cities)){

String[] temp = cities.split(",");

for(int i=0;i

listCities.add(temp[i]);

}

}

List list = jobService.findPage(listJob, listIds, listCities);

JJMdkjNsafreturn new ExtGridReturn(list.size(), list);

} catch (Exception e) {

LOGGER.error("分页获取信息出错", e);

return new ExceptionReturn(e);

}

}

mapper

/**

* 描述:根据工种查询列表

* @param jobCategorys

* @return

*/

List findPage(@Param("jobCategorys") List jobCategorys,@Param("ids") List ids,@Param("workPlace") List workPlace);

xml

JJMdkjNsaf

select n.ID id,

n.NAME name,

n.WORKPLACE workPlace,

n.JOBCATEGORY jobCategory,

n.SALARY salary,

n.RESPONSIBILITIES responsibilities,

n.REQUIREMENTS requirements,

n.ISHOT isHot,

n.UPDATEDATE updateDate,

n.UPDATEUSER updateUser,

u.real_name updateName

from websites_job n

left join base_users u on n.updateUser = u.account

or n.jobCategory in

#{itJJMdkjNsafem}

or n.id in

#{item}

or n.WORKPLACE in

#{item}

order by n.ISHOT,n.ID desc

listCities.add(cityTemp[i]);

}

List list = jobService.findPage(listJob, listIds, listCities);

return new ExtGridReturn(list.size(), list);

}

//按照工种查询

if(StringUtils.isNotBlank(jobCategory)){

String[] temp = jobCategory.split(",");

for(int i=0;i

listJob.add(Integer.valueOf(temp[i]));

}

}

//按照职位名称查询

if(StringUtils.isNotBlank(ids)){

String[] temp = ids.split(",");

for(int i=0;i

listIds.add(Integer.valueOf(temp[i]));

}

}

//按照城市查询

if(StringUtils.isNotBlank(cities)){

String[] temp = cities.split(",");

for(int i=0;i

listCities.add(temp[i]);

}

}

List list = jobService.findPage(listJob, listIds, listCities);

JJMdkjNsafreturn new ExtGridReturn(list.size(), list);

} catch (Exception e) {

LOGGER.error("分页获取信息出错", e);

return new ExceptionReturn(e);

}

}

mapper

/**

* 描述:根据工种查询列表

* @param jobCategorys

* @return

*/

List findPage(@Param("jobCategorys") List jobCategorys,@Param("ids") List ids,@Param("workPlace") List workPlace);

xml

JJMdkjNsaf

select n.ID id,

n.NAME name,

n.WORKPLACE workPlace,

n.JOBCATEGORY jobCategory,

n.SALARY salary,

n.RESPONSIBILITIES responsibilities,

n.REQUIREMENTS requirements,

n.ISHOT isHot,

n.UPDATEDATE updateDate,

n.UPDATEUSER updateUser,

u.real_name updateName

from websites_job n

left join base_users u on n.updateUser = u.account

or n.jobCategory in

#{itJJMdkjNsafem}

or n.id in

#{item}

or n.WORKPLACE in

#{item}

order by n.ISHOT,n.ID desc

listJob.add(Integer.valueOf(temp[i]));

}

}

//按照职位名称查询

if(StringUtils.isNotBlank(ids)){

String[] temp = ids.split(",");

for(int i=0;i

listIds.add(Integer.valueOf(temp[i]));

}

}

//按照城市查询

if(StringUtils.isNotBlank(cities)){

String[] temp = cities.split(",");

for(int i=0;i

listCities.add(temp[i]);

}

}

List list = jobService.findPage(listJob, listIds, listCities);

JJMdkjNsafreturn new ExtGridReturn(list.size(), list);

} catch (Exception e) {

LOGGER.error("分页获取信息出错", e);

return new ExceptionReturn(e);

}

}

mapper

/**

* 描述:根据工种查询列表

* @param jobCategorys

* @return

*/

List findPage(@Param("jobCategorys") List jobCategorys,@Param("ids") List ids,@Param("workPlace") List workPlace);

xml

JJMdkjNsaf

select n.ID id,

n.NAME name,

n.WORKPLACE workPlace,

n.JOBCATEGORY jobCategory,

n.SALARY salary,

n.RESPONSIBILITIES responsibilities,

n.REQUIREMENTS requirements,

n.ISHOT isHot,

n.UPDATEDATE updateDate,

n.UPDATEUSER updateUser,

u.real_name updateName

from websites_job n

left join base_users u on n.updateUser = u.account

or n.jobCategory in

#{itJJMdkjNsafem}

or n.id in

#{item}

or n.WORKPLACE in

#{item}

order by n.ISHOT,n.ID desc

listIds.add(Integer.valueOf(temp[i]));

}

}

//按照城市查询

if(StringUtils.isNotBlank(cities)){

String[] temp = cities.split(",");

for(int i=0;i

listCities.add(temp[i]);

}

}

List list = jobService.findPage(listJob, listIds, listCities);

JJMdkjNsafreturn new ExtGridReturn(list.size(), list);

} catch (Exception e) {

LOGGER.error("分页获取信息出错", e);

return new ExceptionReturn(e);

}

}

mapper

/**

* 描述:根据工种查询列表

* @param jobCategorys

* @return

*/

List findPage(@Param("jobCategorys") List jobCategorys,@Param("ids") List ids,@Param("workPlace") List workPlace);

xml

JJMdkjNsaf

select n.ID id,

n.NAME name,

n.WORKPLACE workPlace,

n.JOBCATEGORY jobCategory,

n.SALARY salary,

n.RESPONSIBILITIES responsibilities,

n.REQUIREMENTS requirements,

n.ISHOT isHot,

n.UPDATEDATE updateDate,

n.UPDATEUSER updateUser,

u.real_name updateName

from websites_job n

left join base_users u on n.updateUser = u.account

or n.jobCategory in

#{itJJMdkjNsafem}

or n.id in

#{item}

or n.WORKPLACE in

#{item}

order by n.ISHOT,n.ID desc

listCities.add(temp[i]);

}

}

List list = jobService.findPage(listJob, listIds, listCities);

JJMdkjNsafreturn new ExtGridReturn(list.size(), list);

} catch (Exception e) {

LOGGER.error("分页获取信息出错", e);

return new ExceptionReturn(e);

}

}

mapper

/**

* 描述:根据工种查询列表

* @param jobCategorys

* @return

*/

List findPage(@Param("jobCategorys") List jobCategorys,@Param("ids") List ids,@Param("workPlace") List workPlace);

xml

JJMdkjNsaf

select n.ID id,

n.NAME name,

n.WORKPLACE workPlace,

n.JOBCATEGORY jobCategory,

n.SALARY salary,

n.RESPONSIBILITIES responsibilities,

n.REQUIREMENTS requirements,

n.ISHOT isHot,

n.UPDATEDATE updateDate,

n.UPDATEUSER updateUser,

u.real_name updateName

from websites_job n

left join base_users u on n.updateUser = u.account

or n.jobCategory in

#{itJJMdkjNsafem}

or n.id in

#{item}

or n.WORKPLACE in

#{item}

order by n.ISHOT,n.ID desc

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:计算机系统-电路设计09-计数器的内部电路实现
下一篇:文件IO-Properties
相关文章

 发表评论

暂时没有评论,来抢沙发吧~