2021与蓝度共同重构项目,服务端
fix
zhanzhiqin
2022-03-18 7d5c887e1bc15e6793b69188622002274f509a7d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
 * @date 2021/11/24 11:15
 */
@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;
    }
}