|
@@ -13,6 +13,7 @@ import com.hfln.portal.common.constant.UserConstants;
|
|
|
import com.hfln.portal.common.constant.redis.RedisCacheConstant;
|
|
|
import com.hfln.portal.common.dto.DevInfoImportDto;
|
|
|
import com.hfln.portal.common.dto.data.device.DeviceDTO;
|
|
|
+import com.hfln.portal.common.dto.data.dic.DicDTO;
|
|
|
import com.hfln.portal.common.dto.data.menu.MenuListDTO;
|
|
|
import com.hfln.portal.common.dto.data.menu.MenuTreeDTO;
|
|
|
import com.hfln.portal.common.dto.data.role.RoleListDTO;
|
|
@@ -89,6 +90,10 @@ public class WebGatewayImpl implements WebGateway {
|
|
|
|
|
|
@Value("${sa-token.admin.active-timeout}")
|
|
|
private long adminActiveTimeout;
|
|
|
+ @Autowired
|
|
|
+ private TblDicService tblDicService;
|
|
|
+ @Autowired
|
|
|
+ private TblDicItemService tblDicItemService;
|
|
|
|
|
|
@Override
|
|
|
public UploadRes uploadDev(MultipartFile file) throws IOException {
|
|
@@ -456,7 +461,9 @@ public class WebGatewayImpl implements WebGateway {
|
|
|
|
|
|
// 转换为DTO
|
|
|
List<MenuListDTO> menuList = CopyUtils.copyList(allMenus, MenuListDTO.class);
|
|
|
-
|
|
|
+ if(menuList == null ){
|
|
|
+ menuList = Collections.emptyList();
|
|
|
+ }
|
|
|
// 根据ParentId进行分组
|
|
|
Map<Long, List<MenuListDTO>> parentMap = menuList.stream()
|
|
|
.collect(Collectors.groupingBy(MenuListDTO::getParentId, Collectors.toList()));
|
|
@@ -520,4 +527,91 @@ public class WebGatewayImpl implements WebGateway {
|
|
|
res.forEach(e -> e.setChildren(buildMenuTree(parentMap, e.getMenuId())));
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addDic(DicAddParam param) {
|
|
|
+ TblDic tblDic = new TblDic();
|
|
|
+ tblDic.setDicType(param.getDicType());
|
|
|
+ tblDic.setDicName(param.getDicName());
|
|
|
+ tblDic.setSort(param.getSort());
|
|
|
+ tblDic.setIsDeleted(BasePO.DeleteFlag.NOT_DELETED);
|
|
|
+ tblDicService.save(tblDic);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateDic(UpdateDicParam param){
|
|
|
+ TblDic tblDic = tblDicService.getById(param.getDicId());
|
|
|
+ if (tblDic == null) {
|
|
|
+ throw new BizException(ErrorEnum.DATA_NOT_EXISTS.getErrorCode(), ErrorEnum.DATA_NOT_EXISTS.getErrorMessage());
|
|
|
+ }
|
|
|
+ tblDic.setDicType(param.getDicType());
|
|
|
+ tblDic.setDicName(param.getDicName());
|
|
|
+ tblDic.setSort(param.getSort());
|
|
|
+ tblDicService.updateById(tblDic);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void deleteDic(Long dicId) {
|
|
|
+ TblDic tblDic = tblDicService.getById(dicId);
|
|
|
+ if (tblDic == null) {
|
|
|
+ throw new BizException(ErrorEnum.DATA_NOT_EXISTS.getErrorCode(), ErrorEnum.DATA_NOT_EXISTS.getErrorMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ //1.删除字典类
|
|
|
+ tblDic.setIsDeleted(BasePO.DeleteFlag.DELETED);
|
|
|
+ tblDicService.removeById(tblDic);
|
|
|
+
|
|
|
+ //2.同步删除字典类下面的字典值
|
|
|
+ tblDicItemService.lambdaUpdate()
|
|
|
+ .set(TblDicItem::getIsDeleted, BasePO.DeleteFlag.DELETED)
|
|
|
+ .eq(TblDicItem::getDicType, tblDic.getDicType())
|
|
|
+ .update();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DicDTO> queryDic() {
|
|
|
+ // 调用底层服务查询所有未删除的字典项
|
|
|
+ List<TblDic> dicList = tblDicService.queryDic();
|
|
|
+ // 转换为DTO并返回
|
|
|
+ return CopyUtils.copyList(dicList, DicDTO.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addDicItem(DicItemAddParam param) {
|
|
|
+ TblDicItem tblDicItem = new TblDicItem();
|
|
|
+ tblDicItem.setDicType(param.getDicType());
|
|
|
+ tblDicItem.setItemCode(param.getItemCode());
|
|
|
+ tblDicItem.setItemName(param.getItemName());
|
|
|
+ tblDicItem.setSort(param.getSort());
|
|
|
+ tblDicItemService.save(tblDicItem);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateDicItem(UpdateDicItemParam param) {
|
|
|
+ TblDicItem tblDicItem = tblDicItemService.getById(param.getItemId());
|
|
|
+
|
|
|
+ if (tblDicItem == null) {
|
|
|
+ throw new BizException(ErrorEnum.DATA_NOT_EXISTS.getErrorCode(), ErrorEnum.DATA_NOT_EXISTS.getErrorMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ tblDicItem.setDicType(param.getDicType());
|
|
|
+ tblDicItem.setItemName(param.getItemName());
|
|
|
+ tblDicItem.setItemCode(param.getItemCode());
|
|
|
+ tblDicItem.setSort(param.getSort());
|
|
|
+ tblDicItemService.updateById(tblDicItem);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void deleteDicItem(Long ItemId) {
|
|
|
+ TblDicItem tblDicItem = tblDicItemService.getById(ItemId);
|
|
|
+
|
|
|
+ if (tblDicItem == null) {
|
|
|
+ throw new BizException(ErrorEnum.DATA_NOT_EXISTS.getErrorCode(), ErrorEnum.DATA_NOT_EXISTS.getErrorMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ tblDicItem.setIsDeleted(BasePO.DeleteFlag.DELETED);
|
|
|
+ tblDicItemService.removeById(tblDicItem);
|
|
|
+ }
|
|
|
+
|
|
|
}
|