您的位置:首页 > 游戏 > 手游 > 009 批量删除

009 批量删除

2024/10/6 12:30:50 来源:https://blog.csdn.net/m0_46695127/article/details/141475162  浏览:    关键词:009 批量删除

文章目录

    • 前端
    • 后端

https://element.eleme.cn/#/zh-CN/component/button

前端

    <el-button type="danger" @click="batchDelete">批量删除</el-button><el-treeref="menuTree"
    batchDelete() {console.log("批量删除菜单...");//封装要删除的idlet ids = [];//通过eltree菜单 获取let checkedNodes = this.$refs.menuTree.getCheckedNodes();console.log("被选中的元素",checkedNodes);for (let index = 0; index < checkedNodes.length; index++) {//把选中的CheckBox的id值 添加到ids集合中ids.push( checkedNodes[index].id );}this.$confirm(`是否批量删除[${ids}]菜单?`, "提示", {confirmButtonText: "确定",cancelButtonText: "取消",type: "warning",}).then(() => {this.$http({url: this.$http.adornUrl("/product/category/delete"),method: "post",data: this.$http.adornData(ids, false),}).then(({ data }) => {this.$message({type: "success",message: "菜单批量删除成功!",});//重新刷新当前菜单this.getMenus();//设置需要默认展开的菜单, 设置为 要删除节点的父节点// this.expandedKey = [node.parent.data.id];});}).catch(() => {});},},

后端

@RestController
@RequestMapping("product/category")
public class CategoryController {/*** 删除*/@RequestMapping("/delete")//@RequiresPermissions("product:category:delete")public R delete(@RequestBody Integer[] ids){//直接删除方式//categoryService.removeByIds(Arrays.asList(ids));//TODO 检查当前要删除的菜单,是否被别的地方引用//逻辑删除方式categoryService.removeMenuByIds(Arrays.asList(ids));return R.ok();}}
@Service("categoryService")
public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity> implements CategoryService {/*** 逻辑删除菜单* @param asList*/@Overridepublic void removeMenuByIds(List<Integer> asList) {//TODO 检查当前要删除的菜单是否被别的地方引用//逻辑删除baseMapper.deleteBatchIds(asList);}
}
#mybatis
mybatis-plus:mapper-locations: classpath*:/mapper/**/*.xml#实体扫描,多个package用逗号或者分号分隔typeAliasesPackage: io.renren.modules.*.entityglobal-config:#数据库相关配置db-config:#主键类型  AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";id-type: AUTOlogic-delete-value: -1logic-not-delete-value: 0banner: false#原生配置configuration:map-underscore-to-camel-case: truecache-enabled: falsecall-setters-on-nulls: truejdbc-type-for-null: 'null'

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com