All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.wslxm.springbootplus2.manage.sys.service.impl.SysRoleMenuServiceImpl Maven / Gradle / Ivy

The newest version!
package io.github.wslxm.springbootplus2.manage.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.github.wslxm.springbootplus2.core.base.service.impl.BaseServiceImpl;
import io.github.wslxm.springbootplus2.manage.sys.mapper.SysRoleMenuMapper;
import io.github.wslxm.springbootplus2.manage.sys.model.entity.SysRoleMenu;
import io.github.wslxm.springbootplus2.manage.sys.service.SysRoleMenuService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
/**
 * @author wangsong
 */
@Service
public class SysRoleMenuServiceImpl extends BaseServiceImpl implements SysRoleMenuService {

    @Override
    public boolean addRoleMenu(String roleId, String menuId) {
        return this.save(new SysRoleMenu(roleId, menuId));
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updRoleMenus(String roleId, List menuIds) {
        this.remove(new LambdaQueryWrapper().eq(SysRoleMenu::getRoleId, roleId));
        if (menuIds == null || menuIds.size() <= 0) {
            return true;
        }
        List roleMenus = new ArrayList<>();
        menuIds.forEach(menuId -> roleMenus.add(new SysRoleMenu(roleId, menuId)));
        return this.saveBatch(roleMenus);
    }


    @Override
    public boolean delBatchByMenuIds(List menuIds) {
        return this.remove(new LambdaQueryWrapper().in(SysRoleMenu::getMenuId, menuIds));
    }

    @Override
    public boolean delByRoleId(String roleId) {
        return this.remove(new LambdaQueryWrapper().eq(SysRoleMenu::getRoleId, roleId));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy