|
|
@ -20,9 +20,13 @@ package com.epmet.service.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
|
import com.epmet.commons.tools.enums.SuperAdminEnum; |
|
|
|
import com.epmet.commons.tools.exception.ErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.security.user.SecurityUser; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.HttpContextUtils; |
|
|
@ -36,7 +40,10 @@ import com.epmet.entity.OperMenuEntity; |
|
|
|
import com.epmet.enums.MenuTypeEnum; |
|
|
|
import com.epmet.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.redis.OperMenuRedis; |
|
|
|
import com.epmet.service.OperLanguageService; |
|
|
|
import com.epmet.service.OperMenuService; |
|
|
|
import com.epmet.service.OperResourceService; |
|
|
|
import com.epmet.service.OperRoleMenuService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -57,6 +64,12 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
|
private OperMenuRedis operMenuRedis; |
|
|
|
@Autowired |
|
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
@Autowired |
|
|
|
private OperRoleMenuService operRoleMenuService; |
|
|
|
@Autowired |
|
|
|
private OperResourceService operResourceService; |
|
|
|
@Autowired |
|
|
|
private OperLanguageService operLanguageService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<OperMenuDTO> page(Map<String, Object> params) { |
|
|
@ -91,16 +104,39 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(OperMenuDTO dto) { |
|
|
|
public void save(OperMenuDTO dto, TokenDto tokenDto) { |
|
|
|
OperMenuEntity entity = ConvertUtils.sourceToTarget(dto, OperMenuEntity.class); |
|
|
|
|
|
|
|
//保存菜单
|
|
|
|
insert(entity); |
|
|
|
saveLanguage(entity.getId(), "name", entity.getName()); |
|
|
|
|
|
|
|
//保存菜单资源
|
|
|
|
operResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); |
|
|
|
|
|
|
|
//清空当前用户,菜单导航、权限标识
|
|
|
|
operMenuRedis.delete(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(OperMenuDTO dto) { |
|
|
|
public void update(OperMenuDTO dto, TokenDto tokenDto) { |
|
|
|
OperMenuEntity entity = ConvertUtils.sourceToTarget(dto, OperMenuEntity.class); |
|
|
|
|
|
|
|
//上级菜单不能为自身
|
|
|
|
if(entity.getId().equals(entity.getPid())){ |
|
|
|
throw new RenException(ErrorCode.SUPERIOR_MENU_ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
//更新菜单
|
|
|
|
updateById(entity); |
|
|
|
saveLanguage(entity.getId(), "name", entity.getName()); |
|
|
|
|
|
|
|
//更新菜单资源
|
|
|
|
operResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); |
|
|
|
|
|
|
|
//清空当前用户,菜单导航、权限标识
|
|
|
|
operMenuRedis.delete(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -110,6 +146,18 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String id, TokenDto tokenDto) { |
|
|
|
//逻辑删除
|
|
|
|
baseDao.deleteBatchIds(Collections.singletonList(id)); |
|
|
|
//删除角色菜单关系
|
|
|
|
operRoleMenuService.deleteByMenuId(id); |
|
|
|
|
|
|
|
//清空当前用户,菜单导航、权限标识
|
|
|
|
operMenuRedis.delete(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<OperMenuDTO> getUserMenuList(TokenDto tokenDto, Integer type) { |
|
|
|
List<OperMenuEntity> menuList; |
|
|
@ -128,6 +176,15 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
|
return TreeUtils.buildTree(dtoList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<OperMenuDTO> getMenuList(Integer type) { |
|
|
|
List<OperMenuEntity> menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage()); |
|
|
|
|
|
|
|
List<OperMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, OperMenuDTO.class); |
|
|
|
|
|
|
|
return TreeUtils.buildTree(dtoList, Constant.OPER_MENU_ROOT); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<OperMenuDTO> getUserMenuNavList(TokenDto tokenDto) { |
|
|
|
List<OperMenuDTO> menuList = operMenuRedis.getUserMenuNavList(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); |
|
|
@ -171,4 +228,15 @@ public class OperMenuServiceImpl extends BaseServiceImpl<OperMenuDao, OperMenuEn |
|
|
|
return permsSet; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<OperMenuDTO> getListPid(String pid) { |
|
|
|
List<OperMenuEntity> menuList = baseDao.getListPid(pid); |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(menuList, OperMenuDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private void saveLanguage(String tableId, String fieldName, String fieldValue){ |
|
|
|
operLanguageService.saveOrUpdate("oper_menu", tableId, fieldName, fieldValue, HttpContextUtils.getLanguage()); |
|
|
|
} |
|
|
|
|
|
|
|
} |