|
@@ -2,6 +2,7 @@ package com.ruoyi.generator.service;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
@@ -338,7 +339,25 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
@Override
|
|
@Override
|
|
public void insertCommunityArticle(CommunityArticle communityArticle) {
|
|
public void insertCommunityArticle(CommunityArticle communityArticle) {
|
|
|
|
|
|
|
|
+ //判断是否传ID 如果有ID贼删除原来的文章 重新插入一条新文章
|
|
|
|
+ if (communityArticle.getId() != null){
|
|
|
|
+ //增加字段 文章编辑字段
|
|
|
|
+ communityArticle.setIsDelete(true);
|
|
|
|
|
|
|
|
+ UpdateWrapper<CommunityArticle> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.eq("id", communityArticle.getId());
|
|
|
|
+
|
|
|
|
+ // 创建一个新的 CommunityArticle 对象,只设置 isDelete 字段
|
|
|
|
+ CommunityArticle updateArticle = new CommunityArticle();
|
|
|
|
+ updateArticle.setIsDelete(communityArticle.getIsDelete());
|
|
|
|
+
|
|
|
|
+ communityArticleService.update(updateArticle, updateWrapper);
|
|
|
|
+
|
|
|
|
+ communityArticle.setParentId(communityArticle.getId());
|
|
|
|
+ communityArticle.setId(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ System.out.println(communityArticle);
|
|
Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
//插入文章信息
|
|
//插入文章信息
|
|
communityArticle.setUserId(userId);
|
|
communityArticle.setUserId(userId);
|