@@ -9,10 +9,13 @@ import com.ningdatech.basic.model.IdVo; | |||||
import com.ningdatech.basic.model.PageVo; | import com.ningdatech.basic.model.PageVo; | ||||
import com.ningdatech.basic.util.CollUtils; | import com.ningdatech.basic.util.CollUtils; | ||||
import com.ningdatech.kqapi.admin.model.entity.Window; | 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.ListWindowReq; | ||||
import com.ningdatech.kqapi.admin.model.req.WindowSaveReq; | import com.ningdatech.kqapi.admin.model.req.WindowSaveReq; | ||||
import com.ningdatech.kqapi.admin.model.vo.WindowDetailVO; | import com.ningdatech.kqapi.admin.model.vo.WindowDetailVO; | ||||
import com.ningdatech.kqapi.admin.service.IWindowService; | 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 com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
@@ -35,7 +38,16 @@ public class WindowManage { | |||||
private final IWindowService windowService; | private final IWindowService windowService; | ||||
private final IKqZzsfwMenuService zzsfwMenuService; | private final IKqZzsfwMenuService zzsfwMenuService; | ||||
public void windowSaveOrUpdate(WindowSaveReq req) { | |||||
public synchronized void windowSaveOrUpdate(WindowSaveReq req) { | |||||
Wrapper<Window> 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); | Window win = BeanUtil.copyProperties(req, Window.class); | ||||
windowService.saveOrUpdate(win); | windowService.saveOrUpdate(win); | ||||
} | } | ||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; | |||||
import cn.hutool.core.collection.CollUtil; | import cn.hutool.core.collection.CollUtil; | ||||
import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; | 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.conditions.query.QueryWrapper; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 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.model.vo.ZoneDetailVO; | ||||
import com.ningdatech.kqapi.admin.service.IWindowService; | import com.ningdatech.kqapi.admin.service.IWindowService; | ||||
import com.ningdatech.kqapi.admin.service.IZoneService; | 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 lombok.RequiredArgsConstructor; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
@@ -40,12 +43,18 @@ import java.util.stream.Collectors; | |||||
public class ZoneManage { | public class ZoneManage { | ||||
private final IZoneService zoneService; | private final IZoneService zoneService; | ||||
private final ZoneMapper zoneMapper; | |||||
private final IWindowService windowService; | private final IWindowService windowService; | ||||
@Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
public synchronized void zoneSaveOrUpdate(ZoneSaveReq req) { | public synchronized void zoneSaveOrUpdate(ZoneSaveReq req) { | ||||
Zone zone = BeanUtil.copyProperties(req, Zone.class); | Zone zone = BeanUtil.copyProperties(req, Zone.class); | ||||
Wrapper<Zone> 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) { | if (zone.getId() != null) { | ||||
Zone oldZone = zoneService.getById(req.getId()); | Zone oldZone = zoneService.getById(req.getId()); | ||||
if (!StrUtil.equals(zone.getZoneName(), oldZone.getZoneName())) { | if (!StrUtil.equals(zone.getZoneName(), oldZone.getZoneName())) { | ||||
@@ -3,7 +3,13 @@ package com.ningdatech.kqapi.zzsfw.manage; | |||||
import cn.hutool.core.bean.BeanUtil; | import cn.hutool.core.bean.BeanUtil; | ||||
import cn.hutool.core.collection.CollUtil; | import cn.hutool.core.collection.CollUtil; | ||||
import cn.hutool.core.lang.Assert; | import cn.hutool.core.lang.Assert; | ||||
import cn.hutool.core.util.StrUtil; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 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.constants.ZzsfwMenuConstant; | ||||
import com.ningdatech.kqapi.zzsfw.enumeration.ItemTypeEnum; | import com.ningdatech.kqapi.zzsfw.enumeration.ItemTypeEnum; | ||||
import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; | import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; | ||||
@@ -58,6 +64,8 @@ public class MatterManage { | |||||
public String password; | public String password; | ||||
private final IKqZzsfwMenuService menuService; | private final IKqZzsfwMenuService menuService; | ||||
private final IZoneService zoneService; | |||||
private final IWindowService windowService; | |||||
private final IKqZzsfwMatterDeduplicateService matterDeduplicateService; | private final IKqZzsfwMatterDeduplicateService matterDeduplicateService; | ||||
@@ -89,6 +97,14 @@ public class MatterManage { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public List<TreeVO> getZones() { | public List<TreeVO> getZones() { | ||||
List<Zone> zones = zoneService.list(); | |||||
return CollUtils.convert(zones, w -> TreeVO.builder() | |||||
.name(w.getZoneName()) | |||||
.type(ZzsfwMenuConstant.MENU_TYPE_ZONE) | |||||
.build()); | |||||
} | |||||
public List<TreeVO> getZonesOld() { | |||||
List<KqZzsfwMenu> matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) | List<KqZzsfwMenu> matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) | ||||
.orderByAsc(KqZzsfwMenu::getSort)); | .orderByAsc(KqZzsfwMenu::getSort)); | ||||
if (CollUtil.isEmpty(matters)) { | if (CollUtil.isEmpty(matters)) { | ||||
@@ -109,6 +125,16 @@ public class MatterManage { | |||||
} | } | ||||
public List<TreeVO> getWindows(String zoneName) { | public List<TreeVO> getWindows(String zoneName) { | ||||
List<Window> 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<TreeVO> getWindowsOld(String zoneName) { | |||||
List<KqZzsfwMenu> matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) | List<KqZzsfwMenu> matters = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) | ||||
.eq(StringUtils.isNotBlank(zoneName), KqZzsfwMenu::getZoneName, zoneName) | .eq(StringUtils.isNotBlank(zoneName), KqZzsfwMenu::getZoneName, zoneName) | ||||
.orderByAsc(KqZzsfwMenu::getSort)); | .orderByAsc(KqZzsfwMenu::getSort)); | ||||
@@ -2,9 +2,10 @@ package com.ningdatech.kqapi.zzsfw.model.vo; | |||||
import io.swagger.annotations.ApiModel; | import io.swagger.annotations.ApiModel; | ||||
import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
import lombok.Builder; | |||||
import lombok.Data; | import lombok.Data; | ||||
import lombok.experimental.Tolerate; | |||||
import java.io.Serializable; | |||||
import java.util.List; | import java.util.List; | ||||
/** | /** | ||||
@@ -16,10 +17,9 @@ import java.util.List; | |||||
* @since 2023-10-25 | * @since 2023-10-25 | ||||
*/ | */ | ||||
@Data | @Data | ||||
@Builder | |||||
@ApiModel(value = "TreeVO", description = "树结构") | @ApiModel(value = "TreeVO", description = "树结构") | ||||
public class TreeVO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
public class TreeVO { | |||||
@ApiModelProperty("rowid") | @ApiModelProperty("rowid") | ||||
private String id; | private String id; | ||||
@@ -53,4 +53,10 @@ public class TreeVO implements Serializable { | |||||
@ApiModelProperty("子级") | @ApiModelProperty("子级") | ||||
private List<TreeVO> chilren; | private List<TreeVO> chilren; | ||||
@Tolerate | |||||
public TreeVO() { | |||||
// 无参构造 | |||||
} | |||||
} | } |