package org.jeecg.modules.dnc.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.jeecg.modules.dnc.entity.MenuButton;
|
import org.jeecg.modules.dnc.exception.ExceptionCast;
|
import org.jeecg.modules.dnc.mapper.MenuButtonMapper;
|
import org.jeecg.modules.dnc.response.MenuCode;
|
import org.jeecg.modules.dnc.service.IMenuButtonService;
|
import org.jeecg.modules.dnc.utils.ValidateUtil;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
@Service
|
public class MenuButtonServiceImpl extends ServiceImpl<MenuButtonMapper, MenuButton> implements IMenuButtonService {
|
@Override
|
@Transactional(rollbackFor = {Exception.class})
|
public boolean deleteByMenuId(String menuId) {
|
if(!ValidateUtil.validateString(menuId))
|
ExceptionCast.cast(MenuCode.MENU_ID_NONE);
|
LambdaQueryWrapper<MenuButton> lambdaUpdate = Wrappers.lambdaQuery();
|
lambdaUpdate.eq(MenuButton::getMenuId, menuId);
|
return super.remove(lambdaUpdate);
|
}
|
|
@Override
|
public Map<String, MenuButton> getMapByMenuId(String menuId) {
|
if(!ValidateUtil.validateString(menuId))
|
return null;
|
List<MenuButton> list = super.lambdaQuery().eq(MenuButton::getMenuId, menuId).list();
|
if(list == null || list.isEmpty())
|
return null;
|
Map<String, MenuButton> map = new HashMap<>();
|
list.forEach(item -> {
|
map.put(item.getButtonId(), item);
|
});
|
return map;
|
}
|
|
@Override
|
public List<MenuButton> findByButtonId(String buttonId) {
|
return super.lambdaQuery().eq(MenuButton::getButtonId, buttonId).list();
|
}
|
}
|