| | |
| | | package com.vci.ubcs.ddl.service.impl; |
| | | |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.alibaba.nacos.shaded.com.google.protobuf.ServiceException; |
| | | import com.vci.ubcs.ddl.bo.DdlTableBO; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.rmi.ServerException; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | private final Map<String, LinkTypeVO> idLinkMap = new ConcurrentHashMap<>(); |
| | | |
| | | private void putBtm(@NotNull BtmTypeVO... voList) throws Throwable { |
| | | private void putBtm(@NotNull BtmTypeVO... voList) throws ServiceException { |
| | | String collect = Arrays.stream(voList).map(BtmTypeVO::getId).filter(idBtmMap::containsKey).collect(Collectors.joining(",")); |
| | | if (StringUtils.isBlank(collect)) { |
| | | Arrays.stream(voList).forEach(vo -> { |
| | | idBtmMap.put(vo.getId(), vo); |
| | | }); |
| | | } else { |
| | | throw new Throwable("业务类型:[" + collect + "]正在被其他用户操作"); |
| | | throw new ServiceException("业务类型:[" + collect + "]正在被其他用户操作"); |
| | | } |
| | | } |
| | | |
| | | private void putLink(@NotNull LinkTypeVO... voList) throws Throwable { |
| | | private void putLink(@NotNull LinkTypeVO... voList) throws ServiceException { |
| | | String collect = Arrays.stream(voList).map(LinkTypeVO::getId).filter(idLinkMap::containsKey).collect(Collectors.joining(",")); |
| | | if (StringUtils.isBlank(collect)) { |
| | | Arrays.stream(voList).forEach(vo -> { |
| | | idLinkMap.put(vo.getId(), vo); |
| | | }); |
| | | } else { |
| | | throw new Throwable("链接类型:[" + collect + "]正在被其他用户操作"); |
| | | throw new ServiceException("链接类型:[" + collect + "]正在被其他用户操作"); |
| | | } |
| | | } |
| | | |
| | |
| | | if (StringUtils.isNotBlank(s.getModifyAttributes()) || StringUtils.isNotBlank(s.getDeleteAttributes())) { |
| | | //需要去判断是否可以更改 |
| | | if (checkTableHasDataByTableName(s.getTableName())) { |
| | | //有数据的话,得需要判断属性是否可以修改 |
| | | //有数据的话,得需要判断属性是否可以删除 |
| | | if (StringUtils.isNotBlank(s.getDeleteAttributes())) { |
| | | s.setHandleResult("表格存在数据,不允许删除字段"); |
| | | s.setHandleResult("表格存在数据,不允许删除"+ s.getDeleteAttributes() +"字段"); |
| | | return; |
| | | } |
| | | List<DdlTableInDataBaseBO> columnInDbList = selectTableColumnInfo(s.getTableName()); |
| | |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public R<List<ModifyAttributeInfo>> submit(BtmAndLinkTypeDdlDTO ddlDTO) throws Throwable { |
| | | public R<List<ModifyAttributeInfo>> submit(BtmAndLinkTypeDdlDTO ddlDTO) throws ServerException { |
| | | try { |
| | | List<ModifyAttributeInfo> changedList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(ddlDTO.getBtmTypeList())) { |
| | |
| | | changedList.addAll(checkDifferent(null,linkTypeList)); |
| | | removeLink(linkTypeList.toArray(new LinkTypeVO[0])); |
| | | } |
| | | String msg = changedList.isEmpty() ? "数据库操作成功" : changedList.get(0).getHandleResult(); |
| | | R<List<ModifyAttributeInfo>> result = R.success(msg); |
| | | String msg = "数据库操作成功"; |
| | | R<List<ModifyAttributeInfo>> result = new R<>(); |
| | | if((!changedList.isEmpty())&&Func.isEmpty(changedList.get(0).getHandleResult())){ |
| | | result = R.success(msg); |
| | | }else { |
| | | result = R.fail(changedList.get(0).getHandleResult()); |
| | | } |
| | | result.setData(changedList); |
| | | return result; |
| | | } catch (Exception e) { |