/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.base.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.base.entity.RoleMenu;
import com.tofly.base.mapper.RoleMenuMapper;
import com.tofly.base.service.RoleMenuService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

/**
 * 角色菜单表
 *
 * @author admin
 * @date Thu Oct 10 00:00:00 CST 2019
 */
@Service("roleMenuService")
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService {

    @Override
    @Transactional
    public boolean updateBatch(RoleMenu[] roleMenus) {
        List<RoleMenu> list= Arrays.asList(roleMenus);
        boolean b=this.remove(Wrappers.<RoleMenu>lambdaQuery()
        .eq(RoleMenu::getRoleId,roleMenus[0].getRoleId()));
        list.forEach(roleMenu -> {
            this.save(roleMenu);
        });
        return true;
    }
}
