MyBatis批量删除

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012303775/article/details/82587287
/**
 * 1.Controller 	
 * 批量删除
 * @param ids
 * @return
 */
@ApiOperation(value = "批量删除")
@Log(desc = "批量删除", type = Log.LOG_TYPE.DEL)
@RequestMapping(value = {"/delAll"}, method= RequestMethod.POST)
@ResponseBody
public JsonUtil delAll(String ids) {
	return billTypeService.delAll(ids);
}

/**
 * 2.Service
 */
JsonUtil delAll(String ids);

/**
 * 3.ServiceImpl
 */
public JsonUtil delAll(String ids) {
  JsonUtil js = new JsonUtil();
  List<String> list = new ArrayList<String>();
  String[] stIds = ids.split(",");
  for (String value : stIds){
	  list.add(value);
  }
  Integer count = billTypeMapper.delAll(list);
  if(count <= 0){
	  js.setMsg("删除失败");
	  js.setFlag(false);
	  return js;
  }
  js.setMsg("删除成功");
  js.setFlag(true);
  return js;
}

/**
 * 4.Mapper 	
 */
int delAll(List<String> ids);

<!--5.Mapper.xml 批量删除 -->
<delete id="delAll" parameterType="java.util.List" >
delete from bill_type where id in
<foreach collection="list" item="ids" open="(" close=")" separator=",">
  #{ids,jdbcType=VARCHAR}
</foreach>
</delete>

 

展开阅读全文

没有更多推荐了,返回首页