wenkai 1 долоо хоног өмнө
parent
commit
dac02e0a04

+ 9 - 1
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/AppEventMdServiceImpl.java

@@ -1,5 +1,7 @@
 package org.dromara.system.service.impl;
 
+import cn.hutool.core.util.StrUtil;
+import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -158,6 +160,12 @@ public class AppEventMdServiceImpl implements IAppEventMdService {
      */
     @Override
     public Boolean editByBo(AppEventMdBo bo) {
+        if (StrUtil.isBlank(bo.getTitle())) {
+            throw new ServiceException("标题不能为空");
+        }
+        if (StrUtil.isBlank(bo.getContent())) {
+            throw new ServiceException("内容不能为空");
+        }
         //查询是否存在
         AppEventMdVo vo = this.queryByEventIdAndType(bo.getEventId(), bo.getType());
         if (Optional.ofNullable(vo).isPresent()) {
@@ -184,7 +192,7 @@ public class AppEventMdServiceImpl implements IAppEventMdService {
         appEventMd.setContent("");
         appEventMd.setType(type);
         appEventMd.setRemark("");
-        return baseMapper.update(appEventMd,Wrappers.lambdaQuery(AppEventMd.class)
+        return baseMapper.update(appEventMd, Wrappers.lambdaQuery(AppEventMd.class)
             .eq(AppEventMd::getEventId, eventId)
             .eq(AppEventMd::getType, type));
     }

+ 15 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/ArticleServiceImpl.java

@@ -31,6 +31,7 @@ import org.dromara.system.service.IArticleService;
 import java.util.List;
 import java.util.Map;
 import java.util.Collection;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -139,6 +140,16 @@ public class ArticleServiceImpl implements IArticleService {
         Object cacheObject = RedisUtils.getCacheObject(GameEventConstant.DEFAULT_EVENT_ID);
         Long defaultEventId = Long.valueOf(cacheObject.toString());
         add.setEventId(defaultEventId);
+        //如果该赛事和类型下没有赛事 必须为默认且不允许隐藏
+        ArticleVo vo = baseMapper.selectVoOne(
+            Wrappers.lambdaQuery(Article.class)
+                .eq(Article::getEventId, defaultEventId)
+                .eq(Article::getType, bo.getType())
+        );
+        if (vo == null) {
+            add.setIsDefault(1);
+            add.setStatus("0");
+        }
         boolean flag = baseMapper.insert(add) > 0;
         if (flag) {
             bo.setId(add.getId());
@@ -243,6 +254,10 @@ public class ArticleServiceImpl implements IArticleService {
             result = this.updateByBo(bo);
             return result;
         }
+        //如果是隐藏
+        if (!Objects.equals(bo.getId(), article.getId()) && bo.getStatus().equals("1")) {
+            throw new ServiceException("默认赛事必须显示");
+        }
         if (article.getId().equals(bo.getId()) && bo.getIsDefault().equals(0)) {
             throw new ServiceException("必须有一个默认文章");
         }