From 2e6277a8cf7a1d78b5151ac42f1aa785205cc907 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 07 Jul 2022 14:18:52 +0800
Subject: [PATCH] finish index

---
 src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
index 8ff8743..6a2ce1d 100644
--- a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
+++ b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
@@ -1,5 +1,6 @@
 package com.xcong.farmer.cms.modules.system.service.Impl;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
@@ -59,6 +60,20 @@
         if(StrUtil.isNotEmpty(title)){
             articleEntity.setTitle(title);
         }
+        Integer contentType = adminArticleDto.getContentType() == null ? 0 : adminArticleDto.getContentType();
+        if(contentType != 0){
+            QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>();
+            objectQueryWrapper.eq("content_type",contentType);
+            List<ColumnEntity> columnEntities = columnMapper.selectList(objectQueryWrapper);
+            if(CollUtil.isNotEmpty(columnEntities)){
+                List<Long> columIds = new ArrayList<>();
+                for(ColumnEntity columnEntity : columnEntities){
+                    Long id = columnEntity.getId();
+                    columIds.add(id);
+                }
+                articleEntity.setColumnIds(columIds);
+            }
+        }
         if(UserEntity.USER_BELONG_TOP != companyId){
             articleEntity.setCompanyId(companyId);
         }
@@ -108,6 +123,7 @@
 
         articleEntity.setArticleUrl(adminAddArticleDto.getArticleUrl());
         articleEntity.setType(adminAddArticleDto.getType());
+        articleEntity.setContentType(adminAddArticleDto.getContentType());
         this.baseMapper.insert(articleEntity);
         return Result.ok("添加成功");
     }
@@ -179,6 +195,7 @@
 
         articleEntity.setArticleUrl(adminUpdateArticleDto.getArticleUrl());
         articleEntity.setType(adminUpdateArticleDto.getType());
+        articleEntity.setContentType(adminUpdateArticleDto.getContentType());
         this.baseMapper.updateById(articleEntity);
         return Result.ok("更新成功");
     }

--
Gitblit v1.9.1