From 17a7acbace717d19e4a474dc71b19d381241fb93 Mon Sep 17 00:00:00 2001 From: liuxiao <1732399289qq.com> Date: Thu, 20 Jun 2024 17:26:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=98=E7=BD=91=20=20=20=E6=96=B0=E9=97=BB?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=96=B0=E5=A2=9E=E6=8E=92=E5=BA=8F=EF=BC=8C?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E7=AD=89=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GwIndexController.java | 3 +- .../controller/GwSlideshowController.java | 6 +-- .../ruoyi/official/domain/bo/GwIndexBo.java | 3 +- .../official/domain/vo/GwSlideshowVo.java | 7 +++- .../official/service/IGwJobInfoService.java | 9 +---- .../service/impl/GwIndexServiceImpl.java | 12 ++++++ .../service/impl/GwSlideshowServiceImpl.java | 39 ++++++++++++++++--- 7 files changed, 58 insertions(+), 21 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/official/controller/GwIndexController.java b/ruoyi-system/src/main/java/com/ruoyi/official/controller/GwIndexController.java index 54b2042..d9f375d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/official/controller/GwIndexController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/official/controller/GwIndexController.java @@ -65,8 +65,7 @@ public class GwIndexController extends BaseController { */ @SaCheckPermission("official:index:query") @GetMapping("/{id}") - public R getInfo(@NotNull(message = "主键不能为空") - @PathVariable Long id) { + public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) { return R.ok(iGwIndexService.queryById(id)); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/official/controller/GwSlideshowController.java b/ruoyi-system/src/main/java/com/ruoyi/official/controller/GwSlideshowController.java index 5d1c0c7..9c54c61 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/official/controller/GwSlideshowController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/official/controller/GwSlideshowController.java @@ -63,15 +63,13 @@ public class GwSlideshowController extends BaseController { } /** - * 获取新闻信息 -详细信息 + * 获取新闻信息详细信息 * * @param id 主键 */ @SaCheckPermission("official:slideshow:query") @GetMapping("/{id}") - public R getInfo(@NotNull(message = "主键不能为空") - @PathVariable Long id) { + public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) { return R.ok(iGwSlideshowService.queryById(id)); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/official/domain/bo/GwIndexBo.java b/ruoyi-system/src/main/java/com/ruoyi/official/domain/bo/GwIndexBo.java index 80cc589..a03a66b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/official/domain/bo/GwIndexBo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/official/domain/bo/GwIndexBo.java @@ -37,11 +37,10 @@ public class GwIndexBo extends BaseEntity { /** * 文件类型 0:图片 1:视频 */ - @NotBlank(message = "文件类型 0:图片 1:视频不能为空", groups = { AddGroup.class, EditGroup.class }) private String fileType; /** - * 业务类型 0:石油化工业务 1:基建业务 2:铁矿石业务 3:燃气业务 + * 业务类型 0:石油化工业务 1:基建业务 2:铁矿石业务 3:燃气业务 */ @NotBlank(message = "业务类型 0:石油化工业务 1:基建业务 2:铁矿石业务 3:燃气业务 不能为空", groups = { AddGroup.class, EditGroup.class }) private String businessType; diff --git a/ruoyi-system/src/main/java/com/ruoyi/official/domain/vo/GwSlideshowVo.java b/ruoyi-system/src/main/java/com/ruoyi/official/domain/vo/GwSlideshowVo.java index 2d38d27..079dfa8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/official/domain/vo/GwSlideshowVo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/official/domain/vo/GwSlideshowVo.java @@ -8,7 +8,7 @@ import com.ruoyi.common.annotation.ExcelDictFormat; import com.ruoyi.common.convert.ExcelDictConvert; import lombok.Data; import java.util.Date; - +import java.util.Map; /** @@ -72,6 +72,11 @@ public class GwSlideshowVo { @ExcelProperty(value = "是否置顶 0:否 1:是") private String isTop; + /** + * 新闻相连的信息 + */ + private Map slideshowMap ; + /** * 创建者id */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/official/service/IGwJobInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/official/service/IGwJobInfoService.java index d5fbb7d..b38ab37 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/official/service/IGwJobInfoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/official/service/IGwJobInfoService.java @@ -10,8 +10,7 @@ import java.util.Collection; import java.util.List; /** - * 招聘信息 -Service接口 + * 招聘信息Service接口 * * @author ruoyi * @date 2024-06-20 @@ -20,7 +19,6 @@ public interface IGwJobInfoService { /** * 查询招聘信息 - */ GwJobInfoVo queryById(Long id); @@ -30,20 +28,17 @@ public interface IGwJobInfoService { TableDataInfo queryPageList(GwJobInfoBo bo, PageQuery pageQuery); /** - * 查询招聘信息 -列表 + * 查询招聘信息列表 */ List queryList(GwJobInfoBo bo); /** * 新增招聘信息 - */ Boolean insertByBo(GwJobInfoBo bo); /** * 修改招聘信息 - */ Boolean updateByBo(GwJobInfoBo bo); diff --git a/ruoyi-system/src/main/java/com/ruoyi/official/service/impl/GwIndexServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/official/service/impl/GwIndexServiceImpl.java index 9b716d4..d74ec68 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/official/service/impl/GwIndexServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/official/service/impl/GwIndexServiceImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.official.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.domain.PageQuery; @@ -109,6 +110,17 @@ public class GwIndexServiceImpl implements IGwIndexService { */ private void validEntityBeforeSave(GwIndex entity){ //TODO 做一些数据校验,如唯一约束 + //存在已置顶的数据不允许添加、编辑 + if (ObjectUtil.isNotEmpty(entity.getId())){ + //编辑 + boolean exists = baseMapper.exists(Wrappers.lambdaQuery().eq(GwIndex::getIsIndex, "1")); + if (exists)throw new RuntimeException("已存在置顶的图片信息!"); + }else { + //新增 + boolean exists = baseMapper.exists(Wrappers.lambdaQuery().eq(GwIndex::getIsIndex, "1")); + if (exists)throw new RuntimeException("已存在置顶的图片信息!"); + } + } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/official/service/impl/GwSlideshowServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/official/service/impl/GwSlideshowServiceImpl.java index e18d234..6a57518 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/official/service/impl/GwSlideshowServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/official/service/impl/GwSlideshowServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.official.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.domain.PageQuery; @@ -15,9 +17,12 @@ import com.ruoyi.official.domain.GwSlideshow; import com.ruoyi.official.mapper.GwSlideshowMapper; import com.ruoyi.official.service.IGwSlideshowService; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Collection; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; /** * 新闻信息 @@ -38,12 +43,25 @@ public class GwSlideshowServiceImpl implements IGwSlideshowService { */ @Override public GwSlideshowVo queryById(Long id){ - return baseMapper.selectVoById(id); + GwSlideshowVo gwSlideshowVo = baseMapper.selectVoById(id); + //查询详情时返回上一篇,下一篇处理 + List list = baseMapper.selectList(Wrappers.lambdaQuery().orderByDesc(GwSlideshow::getCreateTime)); + Map hashMap = new HashMap<>(16); + + if(CollUtil.isNotEmpty(list)){ + List collect = list.stream().map(GwSlideshow::getId).collect(Collectors.toList()); + if (collect.contains(id)){ + int currentSubscript = collect.indexOf(id); + hashMap.put("previous",list.get(currentSubscript-1)); + hashMap.put("nextArticle",list.get(currentSubscript+1)); + gwSlideshowVo.setSlideshowMap(hashMap); + } + } + return gwSlideshowVo; } /** - * 查询新闻信息 -列表 + * 查询新闻信息列表 */ @Override public TableDataInfo queryPageList(GwSlideshowBo bo, PageQuery pageQuery) { @@ -53,8 +71,7 @@ public class GwSlideshowServiceImpl implements IGwSlideshowService { } /** - * 查询新闻信息 -列表 + * 查询新闻信息列表 */ @Override public List queryList(GwSlideshowBo bo) { @@ -74,6 +91,7 @@ public class GwSlideshowServiceImpl implements IGwSlideshowService { lqw.eq(StringUtils.isNotBlank(bo.getIsTop()), GwSlideshow::getIsTop, bo.getIsTop()); lqw.eq(bo.getCreateUserId() != null, GwSlideshow::getCreateUserId, bo.getCreateUserId()); lqw.eq(bo.getUpdateUserId() != null, GwSlideshow::getUpdateUserId, bo.getUpdateUserId()); + lqw.orderByDesc(GwSlideshow::getCreateTime); return lqw; } @@ -108,6 +126,17 @@ public class GwSlideshowServiceImpl implements IGwSlideshowService { */ private void validEntityBeforeSave(GwSlideshow entity){ //TODO 做一些数据校验,如唯一约束 + //存在已置顶的数据不允许添加、编辑 + if (ObjectUtil.isNotEmpty(entity.getId())){ + //编辑 + boolean exists = baseMapper.exists(Wrappers.lambdaQuery().eq(GwSlideshow::getIsTop, "1")); + if (exists)throw new RuntimeException("已存在置顶的图片信息!"); + }else { + //新增 + boolean exists = baseMapper.exists(Wrappers.lambdaQuery().eq(GwSlideshow::getIsTop, "1")); + if (exists)throw new RuntimeException("已存在置顶的图片信息!"); + } + } /**