From 9cb92dc57434bb44ce004e0e8cf2aff27a9a3788 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 23 Apr 2024 10:21:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AA=97=E5=8F=A3=E3=80=81?= =?UTF-8?q?=E4=B8=93=E5=8C=BA=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kqapi/admin/manage/WindowManage.java | 14 +++++++++++- .../ningdatech/kqapi/admin/manage/ZoneManage.java | 11 ++++++++- .../kqapi/zzsfw/manage/MatterManage.java | 26 ++++++++++++++++++++++ .../ningdatech/kqapi/zzsfw/model/vo/TreeVO.java | 14 ++++++++---- 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/kq-vas-api/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java b/kq-vas-api/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java index 6cb9508..b8f144a 100644 --- a/kq-vas-api/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java +++ b/kq-vas-api/src/main/java/com/ningdatech/kqapi/admin/manage/WindowManage.java @@ -9,10 +9,13 @@ import com.ningdatech.basic.model.IdVo; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.kqapi.admin.model.entity.Window; +import com.ningdatech.kqapi.admin.model.entity.Zone; import com.ningdatech.kqapi.admin.model.req.ListWindowReq; import com.ningdatech.kqapi.admin.model.req.WindowSaveReq; import com.ningdatech.kqapi.admin.model.vo.WindowDetailVO; import com.ningdatech.kqapi.admin.service.IWindowService; +import com.ningdatech.kqapi.common.constant.BizConst; +import com.ningdatech.kqapi.common.exception.BizException; import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -35,7 +38,16 @@ public class WindowManage { private final IWindowService windowService; private final IKqZzsfwMenuService zzsfwMenuService; - public void windowSaveOrUpdate(WindowSaveReq req) { + public synchronized void windowSaveOrUpdate(WindowSaveReq req) { + Wrapper nameCheck = Wrappers.lambdaQuery(Window.class) + .eq(Window::getZoneId, req.getZoneId()) + .eq(Window::getWindowName, req.getWindowName()) + .ne(req.getId() != null, Window::getId, req.getId()) + .last(BizConst.LIMIT_1); + if (windowService.count(nameCheck) > 0) { + throw BizException.wrap("您新增的【%s】专区下的【%s】窗口已存在,无须重复添加", + req.getZoneName(), req.getWindowName()); + } Window win = BeanUtil.copyProperties(req, Window.class); windowService.saveOrUpdate(win); } diff --git a/kq-vas-api/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java b/kq-vas-api/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java index 4be4204..ee3b8c2 100644 --- a/kq-vas-api/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java +++ b/kq-vas-api/src/main/java/com/ningdatech/kqapi/admin/manage/ZoneManage.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -18,6 +19,8 @@ import com.ningdatech.kqapi.admin.model.req.ZoneSaveReq; import com.ningdatech.kqapi.admin.model.vo.ZoneDetailVO; import com.ningdatech.kqapi.admin.service.IWindowService; import com.ningdatech.kqapi.admin.service.IZoneService; +import com.ningdatech.kqapi.common.constant.BizConst; +import com.ningdatech.kqapi.common.exception.BizException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -40,12 +43,18 @@ import java.util.stream.Collectors; public class ZoneManage { private final IZoneService zoneService; - private final ZoneMapper zoneMapper; private final IWindowService windowService; @Transactional(rollbackFor = Exception.class) public synchronized void zoneSaveOrUpdate(ZoneSaveReq req) { Zone zone = BeanUtil.copyProperties(req, Zone.class); + Wrapper nameCheck = Wrappers.lambdaQuery(Zone.class) + .eq(Zone::getZoneName, req.getZoneName()) + .ne(req.getId() != null, Zone::getId, req.getId()) + .last(BizConst.LIMIT_1); + if (zoneService.count(nameCheck) > 0) { + throw BizException.wrap("您新增的【%s】专区已存在,无须重复添加", req.getZoneName()); + } if (zone.getId() != null) { Zone oldZone = zoneService.getById(req.getId()); if (!StrUtil.equals(zone.getZoneName(), oldZone.getZoneName())) { diff --git a/kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java b/kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java index 99860eb..5758003 100644 --- a/kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java +++ b/kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java @@ -3,7 +3,13 @@ package com.ningdatech.kqapi.zzsfw.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.kqapi.admin.model.entity.Window; +import com.ningdatech.kqapi.admin.model.entity.Zone; +import com.ningdatech.kqapi.admin.service.IWindowService; +import com.ningdatech.kqapi.admin.service.IZoneService; import com.ningdatech.kqapi.zzsfw.constants.ZzsfwMenuConstant; import com.ningdatech.kqapi.zzsfw.enumeration.ItemTypeEnum; import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; @@ -58,6 +64,8 @@ public class MatterManage { public String password; private final IKqZzsfwMenuService menuService; + private final IZoneService zoneService; + private final IWindowService windowService; private final IKqZzsfwMatterDeduplicateService matterDeduplicateService; @@ -89,6 +97,14 @@ public class MatterManage { * @return */ public List getZones() { + List zones = zoneService.list(); + return CollUtils.convert(zones, w -> TreeVO.builder() + .name(w.getZoneName()) + .type(ZzsfwMenuConstant.MENU_TYPE_ZONE) + .build()); + } + + public List getZonesOld() { List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) .orderByAsc(KqZzsfwMenu::getSort)); if (CollUtil.isEmpty(matters)) { @@ -109,6 +125,16 @@ public class MatterManage { } public List getWindows(String zoneName) { + List windows = windowService.list(Wrappers.lambdaQuery(Window.class) + .eq(StrUtil.isNotBlank(zoneName), Window::getZoneName, zoneName)); + return CollUtils.convert(windows, w -> TreeVO.builder() + .name(w.getWindowName()) + .type(ZzsfwMenuConstant.MENU_TYPE_WINDOW) + .build()); + } + + @Deprecated + public List getWindowsOld(String zoneName) { List matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) .eq(StringUtils.isNotBlank(zoneName), KqZzsfwMenu::getZoneName, zoneName) .orderByAsc(KqZzsfwMenu::getSort)); diff --git a/kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java b/kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java index 18b020f..94f2d14 100644 --- a/kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java +++ b/kq-vas-api/src/main/java/com/ningdatech/kqapi/zzsfw/model/vo/TreeVO.java @@ -2,9 +2,10 @@ package com.ningdatech.kqapi.zzsfw.model.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; import lombok.Data; +import lombok.experimental.Tolerate; -import java.io.Serializable; import java.util.List; /** @@ -16,10 +17,9 @@ import java.util.List; * @since 2023-10-25 */ @Data +@Builder @ApiModel(value = "TreeVO", description = "树结构") -public class TreeVO implements Serializable { - - private static final long serialVersionUID = 1L; +public class TreeVO { @ApiModelProperty("rowid") private String id; @@ -53,4 +53,10 @@ public class TreeVO implements Serializable { @ApiModelProperty("子级") private List chilren; + + @Tolerate + public TreeVO() { + // 无参构造 + } + }