官网 新闻动态新增排序,校验等逻辑

This commit is contained in:
liuxiao 2024-06-20 17:26:30 +08:00
parent 3dbf4a9fa6
commit 17a7acbace
7 changed files with 58 additions and 21 deletions

View File

@ -65,8 +65,7 @@ public class GwIndexController extends BaseController {
*/
@SaCheckPermission("official:index:query")
@GetMapping("/{id}")
public R<GwIndexVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
public R<GwIndexVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
return R.ok(iGwIndexService.queryById(id));
}

View File

@ -63,15 +63,13 @@ public class GwSlideshowController extends BaseController {
}
/**
* 获取新闻信息
详细信息
* 获取新闻信息详细信息
*
* @param id 主键
*/
@SaCheckPermission("official:slideshow:query")
@GetMapping("/{id}")
public R<GwSlideshowVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
public R<GwSlideshowVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
return R.ok(iGwSlideshowService.queryById(id));
}

View File

@ -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;

View File

@ -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<String,Object> slideshowMap ;
/**
* 创建者id
*/

View File

@ -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<GwJobInfoVo> queryPageList(GwJobInfoBo bo, PageQuery pageQuery);
/**
* 查询招聘信息
列表
* 查询招聘信息列表
*/
List<GwJobInfoVo> queryList(GwJobInfoBo bo);
/**
* 新增招聘信息
*/
Boolean insertByBo(GwJobInfoBo bo);
/**
* 修改招聘信息
*/
Boolean updateByBo(GwJobInfoBo bo);

View File

@ -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.<GwIndex>lambdaQuery().eq(GwIndex::getIsIndex, "1"));
if (exists)throw new RuntimeException("已存在置顶的图片信息!");
}else {
//新增
boolean exists = baseMapper.exists(Wrappers.<GwIndex>lambdaQuery().eq(GwIndex::getIsIndex, "1"));
if (exists)throw new RuntimeException("已存在置顶的图片信息!");
}
}
/**

View File

@ -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<GwSlideshow> list = baseMapper.selectList(Wrappers.<GwSlideshow>lambdaQuery().orderByDesc(GwSlideshow::getCreateTime));
Map<String, Object> hashMap = new HashMap<>(16);
if(CollUtil.isNotEmpty(list)){
List<Long> 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<GwSlideshowVo> queryPageList(GwSlideshowBo bo, PageQuery pageQuery) {
@ -53,8 +71,7 @@ public class GwSlideshowServiceImpl implements IGwSlideshowService {
}
/**
* 查询新闻信息
列表
* 查询新闻信息列表
*/
@Override
public List<GwSlideshowVo> 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.<GwSlideshow>lambdaQuery().eq(GwSlideshow::getIsTop, "1"));
if (exists)throw new RuntimeException("已存在置顶的图片信息!");
}else {
//新增
boolean exists = baseMapper.exists(Wrappers.<GwSlideshow>lambdaQuery().eq(GwSlideshow::getIsTop, "1"));
if (exists)throw new RuntimeException("已存在置顶的图片信息!");
}
}
/**