jeefast 传递多个不同类型参数到map文件 (类集和普通变量)

jeefast 传递多个不同类型参数到map文件 (类集和普通变量)

在jeefast 或者其他框架的时候 经常会遇到需要传多个值而且还不停类型的,那怎么办呢???

以修改状态为例:0:显示 1:隐藏

控制器:

/**
	 *状态通知
	 */
	@Log("状态通知")
	@RequestMapping("/zt")
	@RequiresPermissions("platform:notice:zt")
	public R zt(@RequestBody Long[] noticeIds){
		//pfNoticeService.updateBatch(noticeIds);
		for (int i = 0; i < noticeIds.length; i++) {
			PfNotice pfNotice=pfNoticeService.selectById(noticeIds[i]);
			List<Long> ids=new ArrayList<Long>();
			Integer id=0;
			if (pfNotice.getXs()==0) { 
				 id=1; 
			}
			for (int j = 0; j < noticeIds.length; j++) {
				ids.add(noticeIds[i]);
			}
			pfNoticeService.updateBath(ids,id);
		}
		return R.ok();
	}

其中ids是要修改的id号,id是状态,

service:

void updateBath(List<? extends Serializable> ids, Integer id);

impl:

@Override
	public void updateBath(List<? extends Serializable> ids, Integer id) {
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("ids", ids);
		map.put("id", id);
		pfNoticeDao.updateBath(map);
	}

dao:

void updateBath(Map<String, Object> map);

xml:

<update id="updateBath">
	UPDATE pf_notice  SET  xs=#{id}
	WHERE id in
	<foreach item="ids" collection="ids" open="(" separator="," close=")">
		#{ids}
	</foreach>
</update>

这样就可以实现同时改变多个的状态,

如果在控制器中通过for循环一个个的修改状态也能实现但是在效率方面,远不如这种方法

发布了34 篇原创文章 · 获赞 5 · 访问量 2256

猜你喜欢

转载自blog.csdn.net/tanfei_/article/details/103452680
今日推荐