1.对于规格参数的批量删除,是前台传过来几个ID,我们通过 “,” 对其进行切分,然后遍历的去删除对应ID的param就可以了。这当然涉及到数据库的操作,所以我们需要先写出通过ID删除对应Param的dubbo代码。现给出实现类的代码:
public int delByIds(String ids) throws Exception {
// TODO Auto-generated method stub
int index=0;
String[] idStrings=ids.split(",");
for(String id:idStrings) {
index=+tbItemParamMapper.deleteByPrimaryKey(Long.parseLong(id));
}
if(index==idStrings.length) {
return 1;
}else {
throw new Exception("删除失败。可能原因:数据可能已经不存在!");
}
}
2.字后我们去manage里面去写对应的服务代码。通过调用对应的dubbo来进行删除。给出实现类的代码:
public int delByIds(String ids) throws Exception {
// TODO Auto-generated method stub
return tbItemParamDubboServiceImpl.delByIds(ids);
}
3.我们再给出对应的控制器的代码:
@RequestMapping("item/param/delete")
@ResponseBody
public EgoResult delByIds(String ids) {
EgoResult er=new EgoResult();
try {
int index=tbItemParamServiceImpl.delByIds(ids);
if(index==1) {
er.setStatus(200);
}
} catch (Exception e) {
// TODO Auto-generated catch block
//e.printStackTrace();
er.setData(e.getMessage());
}
return er;