| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.dao.domain.RoleMenuRelation; |
| | | import com.sandu.ximon.dao.mapper.RoleMenuRelationMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | |
| | | */ |
| | | @Service |
| | | public class RoleMenuRelationService extends BaseServiceImpl<RoleMenuRelationMapper, RoleMenuRelation> { |
| | | |
| | | public boolean addRoleMenuList(Long roleId, List<Long> menuIdList) { |
| | | if (CollectionUtil.isNotEmpty(menuIdList)) { |
| | | List<RoleMenuRelation> roleMenuRelationList = new ArrayList<>(); |
| | | for (Long menuId : menuIdList) { |
| | | RoleMenuRelation roleMenuRelation = new RoleMenuRelation(); |
| | | roleMenuRelation.setMenuId(menuId); |
| | | roleMenuRelation.setRoleId(roleId); |
| | | roleMenuRelationList.add(roleMenuRelation); |
| | | } |
| | | if (!saveBatch(roleMenuRelationList)) { |
| | | throw new BusinessException("编辑角色菜单失败"); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |