Browse Source

fix: 解决站点更新时排序会递增的问题

zhongwei
liwen 8 months ago
parent
commit
6554520c19
  1. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -89,8 +89,11 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
Assert.isTrue(this.buildDept(req), () -> { Assert.isTrue(this.buildDept(req), () -> {
throw new ServiceException("创建/修改机构失败!"); throw new ServiceException("创建/修改机构失败!");
}); });
Optional<Integer> sort = Optional.ofNullable(this.getStationMaxOrder()); // 区分新增和修改站点信息,若为新增,则排序递增,否则不变
req.setSort(sort.isPresent() ? sort.get() + 1 : 1); if (req.getId() == null) {
Optional<Integer> sort = Optional.ofNullable(this.getStationMaxOrder());
req.setSort(sort.isPresent() ? sort.get() + 1 : 1);
}
boolean updateResult = this.saveOrUpdate(req); boolean updateResult = this.saveOrUpdate(req);
Assert.isTrue(updateResult, () -> { Assert.isTrue(updateResult, () -> {
throw new ServiceException("创建/修改站点信息失败!"); throw new ServiceException("创建/修改站点信息失败!");

Loading…
Cancel
Save