package com.gkhy.safePlatform.account.service.baseService.impl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.gkhy.safePlatform.account.entity.user.RoleMenuInfo;
|
import com.gkhy.safePlatform.account.repository.RoleMenuInfoRepository;
|
import com.gkhy.safePlatform.account.service.baseService.RoleMenuInfoService;
|
import com.gkhy.safePlatform.commons.enums.ResultCodes;
|
import com.gkhy.safePlatform.commons.exception.BusinessException;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Collection;
|
|
@Service("roleMenuInfoService")
|
public class RoleMenuInfoServiceImpl extends ServiceImpl<RoleMenuInfoRepository, RoleMenuInfo> implements RoleMenuInfoService {
|
|
@Autowired
|
private RoleMenuInfoRepository roleMenuInfoRepository;
|
|
@Override
|
public void unbindRoleByMenuId(Long menuId) {
|
if (menuId == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
roleMenuInfoRepository.deleteByMenuId(menuId);
|
}
|
|
|
@Override
|
public void saveRoleMenus(Collection<RoleMenuInfo> roleMenuInfos) {
|
if (roleMenuInfos == null || roleMenuInfos.size() == 0) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
int i = roleMenuInfoRepository.insertBatch(roleMenuInfos);
|
if (i != roleMenuInfos.size()) {
|
throw new BusinessException(ResultCodes.SERVER_BATCH_ADD_ERROR);
|
}
|
}
|
|
@Override
|
public void unbindMenuByRoleId(Long roleId) {
|
if (roleId == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
roleMenuInfoRepository.deleteByRoleId(roleId);
|
}
|
}
|