js:
var rows = $("#stu_reg_table").datagrid("getSelections");if(rows != ""){$.messager.confirm("系统确认","您确认同意该申请吗?",function (r) {if(r){var id=[];for(i=0;i<rows.length;i++){ id.push(rows[i].id);}//alert(id)$.ajax({url: 'agree-reg',data:{ids:id},//traditional:是否使用传统的方式浅层序列化。必须要写traditional:true, //默认falsetype:"GET",success: function(data){if(data.status == 200){// 消息将显示在右下角$.messager.show({title:'系统消息',msg:'审核成功,此提示将在2秒后关闭。',timeout:2000,showType:'slide'});//修改数据后刷新$("#stu_reg_table").datagrid('reload');}}})}})}else {$.messager.alert("系统信息","请<b>至少选择一行</b>要审核的信息")}
Controller接收:
@GetMapping("agree-reg")@ResponseBodypublic CustomResult agreeReg(Integer[] ids){List<Integer> uid = new ArrayList<>();for (Integer id:ids) {uid.add(id);}System.out.println(uid);CustomResult result = userService.agreeReg(uid);result.setStatus(200);//System.out.println("============="+ Arrays.toString(ids));return result;}
MyBatis逆向工程批量更新操作:
UserService.java:
//批量授权审核 CustomResult agreeReg(List<Integer> uid);
UserServiceImpl.java:
/*** @Description //批量更新* @Date 2019-04-03 15:10* @Param [uid]* @return com.sun123.springboot.CustomResult**/@Overridepublic CustomResult agreeReg(List<Integer> uid) {User user = new User(); //修改用户为普通用户user.setRole(2);UserExample userExample = new UserExample();UserExample.Criteria criteria = userExample.createCriteria();//批量修改 criteria.andIdIn(uid);userMapper.updateByExampleSelective(user,userExample); return CustomResult.ok();}