关于删除(删除单个与多个)

      一 Dao层:

        private static final String HQL_DELETE_ALL = "DELETE FROM UploadTrack";


public void deleteAll() {

this.bulkUpdate(HQL_DELETE_ALL);

}


   二 service层:

        @Override
@Transactional (删除一个)
public void removeUploadTrack(Long[] ids) {
if (ArrayUtils.isNotEmpty(ids)) {
for (Long id : ids) {
this.uploadTrackDAO.deleteById(id);
}
}
}


        @Override
@Transactional(删除所有)
public void removeAll() {
this.uploadTrackDAO.deleteAll();
}


三 Controller层:

@RequestMapping("/removeUploadTrack")
@RequireLogin
@ResponseBody
@AccessControl("user_mgr_detail")
public ResultResponse removeUploadTrack(Long[] errorBox) {

ResultResponse rr = new ResultResponse();

try {
uploadTrackService.removeUploadTrack(errorBox);
rr.setResult(true);
} catch (Exception e) {
rr.setResult(false);
rr.setMessage("remove the UploadTrack fail !!!");
e.printStackTrace();
}
return rr;
}

@RequestMapping("/removeAll")
@RequireLogin
@ResponseBody
public ResultResponse RemoveAll() {
ResultResponse rr = new ResultResponse();
try {
uploadTrackService.removeAll();
rr.setResult(true);
} catch (Exception e) {
rr.setResult(false);
rr.setMessage("Remove all UploadTrack fail !!!");
e.printStackTrace();
}
return rr;
}



四 jsp层:

function del(){
if ($("input[name='errorBox']:checked").length>0) { 
$.confirm("Are You Sure to Delete This?", {ok:function(){
$.post("${path}/arwen/uploadTrack/removeUploadTrack", $("input[name='errorBox']").serialize(), function(result) {
if (result.result) {
   window.location.reload();
} else {
alert(result.message);
}
})
}})
}
}

function delAll(){
$.confirm("Are You Sure to Delete All This?", {ok:function(){
$.post("${path}/arwen/uploadTrack/removeAll", function(result) {
if (result.result) {
   window.location.reload();
} else {
alert(result.message);
}
})
}})
}


$(document).ready(function(){

$("input[type='checkbox']:not(.simple)").iCheck({
 /* handle: 'checkbox' */
/* checkboxClass: 'icheckbox' */
checkboxClass: 'icheckbox_minimal'
});
 
$("#selectAll").on('ifChecked', function(event){
  $("tbody input").iCheck('check');
}); 
$("#selectAll").on('ifUnchecked', function(event){
$("tbody input").iCheck('uncheck');
}); 

});



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值