删除一个产品

1.product-view.jsp
<div class="page-container" style="padding-top: 15px; padding-left: 25px; padding-right: 25px;">
<div class="cl pd-5 bg-1 bk-gray mt-20 radius">
<span class="l"><a href="javascript:;" οnclick="add()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe604;</i> 添加产品</a>
<a href="javascript:;" οnclick="removes()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> </span>
</div>
<div class="mt-20">
<table class="table table-border table-bordered table-hover table-bg table-sort" id="userTable">
<thead>
<tr class="text-c">
<th width="25"><input type="checkbox" name="" value=""></th>
<th width="">产品名称</th>
<th width="">产品价格</th>
<th width="">产品库存</th>
<th width="">产品状态</th>
<th width="130">操作</th>
</tr>
</thead>
<tbody class="text-c">
</tbody>
</table>
</div>
</div>
2.脚本
/*删除*/
function remove(obj,id){
var tr = $(obj).parents("tr");
var input = tr.find("input");
layer.confirm('确认要删除吗?',function(index){
$.ajax({
'url' : '/web10-7/product/remove',
'type' : 'post',
'dataType' : 'json',
'data' : {"id" : input.val()},
'success' : function(data, statusText) {
if(data.status){
layer.msg("删除成功!");
table.ajax.reload();
}else{
layer.msg("删除失败!");
}
},
'error' : function(xhr, e1, e2) {
layer.msg("系统错误!");
}
});
});
}
3.ProductAction.java
/**
* 删除产品
*/
@ResponseBody
@RequestMapping("/remove")
public CallbackResult removeUser(HttpServletRequest request){
String id = request.getParameter("id");
Product product=new Product();
product.setId(id);
CallbackResult callbackResult = new CallbackResult();
callbackResult.setStatus(productService.remove(product));
return callbackResult;
}

4.ProductService.java
public Boolean remove(Product product) {
return productDao.remove(product) == 1;
}

5.ProductMapper.xml
<update id="remove" parameterType="fuck.pojo.Product" flushCache="true">
update product set status = 0 where id = #{id}
</update>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值