springMVC+myBatis批量删除,多个参数(Oracle数据库)

myBaits xml:

<!-- 根据用户编号批量删除该用户下某些角色 -->
<delete id="batchDeleteUserRoleByUserId" parameterType="Map">
  delete from zj_webdesk_user_role_tbl where user_id=#{userId,jdbcType=DECIMAL} and role_id in
  <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
    #{item}
  </foreach>
</delete>

 

Mapper接口:

int batchDeleteUserRoleByUserId(Map<String,Object> map);

Service接口:

int batchDeleteUserRoleByUserId(Map<String,Object> map);

ServiceImpl:

@Override
public int batchDeleteUserRoleByUserId(Map<String, Object> map) {
return userRoleCMapper.batchDeleteUserRoleByUserId(map);
}

Controller:

@ApiOperation(value = "批量删除某个角色的某些角色", notes = "用户编号,角色编号")
@RequestMapping(value = "/user/deleteUserRole/{userId}", method = { RequestMethod.POST, RequestMethod.GET })
public ResultMap deleteUserRoleByUserId(@PathVariable("userId") int userId,@RequestParam("roleIds") int[] roleIds) {
ResultMap rs = new ResultMap();
Map<String,Object> map= new HashMap<String,Object>();
map.put("userId", userId);
List<Integer> list = new ArrayList<Integer>(roleIds.length);
for(int i=0;i<roleIds.length;i++){
list.add(roleIds[i]);
}
map.put("list", list);
int result = userRoleServiceImpl.batchDeleteUserRoleByUserId(map);
rs.addData("result", result);
return rs;
}

 

posted @ 2017-03-17 09:17  BingoTiger  阅读(920)  评论(0)    收藏  举报