瀏覽代碼

新增文章发布文章获取等方法优化

fangzhen 8 月之前
父節點
當前提交
b6acd442d4

+ 19 - 5
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityArticleController.java

@@ -55,6 +55,18 @@ public class CommunityArticleController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 发布文章
+     */
+    @ApiOperation("发布文章")
+    @PostMapping("/article")
+    //@Anonymous
+    public AjaxResult article(@RequestBody CommunityArticle communityArticle) {
+        communityArticleService.insertCommunityArticle(communityArticle);
+        return AjaxResult.success("文章发布成功!");
+    }
+
+
     @GetMapping("/class")
     @ApiOperation("获取文章分类列表")
     //@Anonymous
@@ -147,27 +159,29 @@ public class CommunityArticleController extends BaseController {
 
 
     /**
-     * 文章点赞
+     * 评论点赞
      */
     @ApiOperation("评论点赞")
     @PostMapping("/commentLike")
     //@Anonymous
     public AjaxResult commentLike(@RequestBody CommunityCommentLike commentLike) {
-        if (Objects.isNull(commentLike.getCommentId()) || Objects.isNull(commentLike.getUserId())) {
+        if (Objects.isNull(commentLike.getCommentId())) {
             return AjaxResult.error("评论或用户信息异常!");
         }
+        Long userId = SecurityUtils.getLoginUser().getUserId();
         boolean isSuccess = true;
         String message = "";
         //查询该评论是否已点赞
         List<CommunityCommentLike> commentLikes = communityCommentLikeMapper
                 .selectList(new QueryWrapper<CommunityCommentLike>()
                         .eq("comment_id", commentLike.getCommentId())
-                        .eq("user_id", commentLike.getUserId()));
+                        .eq("user_id", userId));
 
         if (commentLikes.isEmpty()) {
             //新增点赞
-            commentLike.setCreateBy(SecurityUtils.getLoginUser().getUserId());
-            commentLike.setUpdateBy(SecurityUtils.getLoginUser().getUserId());
+            commentLike.setCreateBy(userId);
+            commentLike.setUserId(userId);
+            commentLike.setUpdateBy(userId);
             commentLike.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
             commentLike.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
             communityCommentLikeMapper.insert(commentLike);

+ 65 - 24
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticle.java

@@ -1,10 +1,13 @@
 package com.ruoyi.generator.domain.Community;
 
-import com.ruoyi.common.core.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import org.hibernate.validator.constraints.Length;
 
@@ -12,35 +15,37 @@ import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
 
 /**
-* 
-* @TableName community_article
-*/
+ * @TableName community_article
+ */
 @Data
-@EqualsAndHashCode(callSuper = true)
 @NoArgsConstructor
 @AllArgsConstructor
-public class CommunityArticle extends BaseEntity implements Serializable {
+@TableName("community_article")
+public class CommunityArticle implements Serializable {
 
     /**
-    * 文章id
-    */
-    @NotNull(message="[文章id]不能为空")
+     * 文章id
+     */
+    @NotNull(message = "[文章id]不能为空")
     @ApiModelProperty("文章id")
+    @TableId(value = "id", type = IdType.AUTO)
     private Long id;
     /**
-    * 创建人id
-    */
-    @NotNull(message="[创建人id]不能为空")
+     * 创建人id
+     */
+    @NotNull(message = "[创建人id]不能为空")
     @ApiModelProperty("创建人id")
-    private Integer userId;
+    private Long userId;
     /**
-    * 文章标题
-    */
-    @NotBlank(message="[文章标题]不能为空")
-    @Size(max= 255,message="编码长度不能超过255")
-    @Length(max= 255,message="编码长度不能超过255")
+     * 文章标题
+     */
+    @NotBlank(message = "[文章标题]不能为空")
+    @Size(max = 255, message = "编码长度不能超过255")
+    @Length(max = 255, message = "编码长度不能超过255")
     @ApiModelProperty("文章标题")
     private String title;
 
@@ -48,17 +53,53 @@ public class CommunityArticle extends BaseEntity implements Serializable {
      * 分类id
      */
     @ApiModelProperty("分类id")
-    private String classId;
+    private Long classId;
 
     /**
-    * 文章内容
-    */
+     * 文章内容
+     */
     @ApiModelProperty("文章内容")
     private String content;
 
     /**
-     * 文章内容
+     * 文章标签
+     */
+    @ApiModelProperty("文章标签")
+    @TableField(exist = false)
+    private List<CommunityTag> tags;
+
+    /**
+     * 图片地址
+     */
+    @ApiModelProperty("图片地址")
+    @TableField(exist = false)
+    private List<String> images;
+
+    /**
+     * 是否允许评价
      */
     @ApiModelProperty("是否允许评价")
-    private String isComment;
+    private boolean isComment;
+
+    /**
+     * 创建者
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 更新者
+     */
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
 }

+ 25 - 5
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticleImages.java

@@ -1,27 +1,32 @@
 package com.ruoyi.generator.domain.Community;
 
-import com.ruoyi.common.core.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * 文章上传的图片
  * @TableName community_article_images
  */
-@EqualsAndHashCode(callSuper = true)
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
-public class CommunityArticleImages extends BaseEntity implements Serializable {
+@TableName("community_article_images")
+public class CommunityArticleImages implements Serializable {
+    private static final long serialVersionUID = 1L;
     /**
      * 图片id
      */
     @ApiModelProperty("图片id")
+    @TableId("id")
     private Long id;
 
     /**
@@ -34,7 +39,22 @@ public class CommunityArticleImages extends BaseEntity implements Serializable {
      * 图片地址
      */
     @ApiModelProperty("图片地址")
+    @TableField("images_url")
     private String imageUrl;
 
-    private static final long serialVersionUID = 1L;
+
+
+    /** 创建者 */
+    private Long createBy;
+
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /** 更新者 */
+    private Long updateBy;
+
+    /** 更新时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
 }

+ 58 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticleTag.java

@@ -0,0 +1,58 @@
+package com.ruoyi.generator.domain.Community;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+* 文章标签关联表
+* @TableName community_article_tag
+*/
+@Data
+@TableName("community_article_tag")
+public class CommunityArticleTag implements Serializable {
+
+    /**
+    * 唯一id
+    */
+    @TableId("id")
+    @NotNull(message="[唯一id]不能为空")
+    @ApiModelProperty("唯一id")
+    private Long id;
+    /**
+    * 文章id
+    */
+    @ApiModelProperty("文章id")
+    private Long articleId;
+    /**
+    * 标签id
+    */
+    @ApiModelProperty("标签id")
+    private Long tagId;
+    /**
+    * 创建人
+    */
+    @ApiModelProperty("创建人")
+    private Long createBy;
+    /**
+    * 创建时间
+    */
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+    /**
+    * 更新人
+    */
+    @ApiModelProperty("更新人")
+    private Long updateBy;
+    /**
+    * 更新时间
+    */
+    @ApiModelProperty("更新时间")
+    private Date updateTime;
+
+}

+ 59 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityTag.java

@@ -0,0 +1,59 @@
+package com.ruoyi.generator.domain.Community;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+* 
+* @TableName community_tag
+*/
+@Data
+@TableName("community_tag")
+public class CommunityTag implements Serializable {
+
+    /**
+    * 标签id
+    */
+    @NotNull(message="[标签id]不能为空")
+    @ApiModelProperty("标签id")
+    @TableId("id")
+    private Long id;
+    /**
+    * 标签名称
+    */
+    @NotBlank(message="[标签名称]不能为空")
+    @Size(max= 255,message="编码长度不能超过255")
+    @ApiModelProperty("标签名称")
+    @Length(max= 255,message="编码长度不能超过255")
+    private String tagName;
+    /**
+    * 创建人
+    */
+    @ApiModelProperty("创建人")
+    private Long createBy;
+    /**
+    * 创建时间
+    */
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+    /**
+    * 更新人
+    */
+    @ApiModelProperty("更新人")
+    private Long updateBy;
+    /**
+    * 更新时间
+    */
+    @ApiModelProperty("更新时间")
+    private Date updateTime;
+
+}

+ 2 - 12
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleImagesMapper.java

@@ -2,6 +2,7 @@ package com.ruoyi.generator.mapper.community;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.generator.domain.Community.CommunityArticleImages;
+import org.apache.ibatis.annotations.Mapper;
 
 /**
 * @author Administrator
@@ -9,18 +10,7 @@ import com.ruoyi.generator.domain.Community.CommunityArticleImages;
 * @createDate 2024-08-24 17:04:17
 * @Entity com.ruoyi.generator.domain.Community.CommunityArticleImages
 */
+@Mapper
 public interface CommunityArticleImagesMapper extends BaseMapper<CommunityArticleImages> {
 
-    int deleteByPrimaryKey(Long id);
-
-    int insert(CommunityArticleImages record);
-
-    int insertSelective(CommunityArticleImages record);
-
-    CommunityArticleImages selectByPrimaryKey(Long id);
-
-    int updateByPrimaryKeySelective(CommunityArticleImages record);
-
-    int updateByPrimaryKey(CommunityArticleImages record);
-
 }

+ 9 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleTagMapper.java

@@ -0,0 +1,9 @@
+package com.ruoyi.generator.mapper.community;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.generator.domain.Community.CommunityArticleTag;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface CommunityArticleTagMapper extends BaseMapper<CommunityArticleTag> {
+}

+ 9 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityTagMapper.java

@@ -0,0 +1,9 @@
+package com.ruoyi.generator.mapper.community;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.generator.domain.Community.CommunityTag;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface CommunityTagMapper extends BaseMapper<CommunityTag> {
+}

+ 86 - 13
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.text.ParseException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 
@@ -46,6 +47,18 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
     @Autowired
     private CommunityCommentLikeMapper communityCommentLikeMapper;
 
+    @Autowired
+    private CommunityArticleTagMapper articleTagMapper;
+
+    @Autowired
+    private CommunityArticleTagMapper communityArticleTagMapper;
+
+    @Autowired
+    private CommunityTagMapper communityTagMapper;
+
+    @Autowired
+    private CommunityArticleImagesMapper communityArticleImagesMapper;
+
     /**
      * 查询文章列表
      *
@@ -81,26 +94,86 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
                         .selectList(new QueryWrapper<CommunityCommentLike>()
                                 .eq("comment_id", communityArticleCommentVo.getId()))
                         .size());
+            }
+
+            //判断是否已收藏
+            CommunityArticleCollect collect = communityCollectMapper
+                    .selectOne(new QueryWrapper<CommunityArticleCollect>()
+                            .eq("user_id", userId)
+                            .eq("article_id", articleVo.getId()));
+            articleVo.setCollect(!Objects.isNull(collect));
+
+            //判断是否已点赞
+            CommunityLike like = communityLikeMapper
+                    .selectOne(new QueryWrapper<CommunityLike>()
+                            .eq("user_id", userId)
+                            .eq("article_id", articleVo.getId()));
+            articleVo.setLike(!Objects.isNull(like));
+
+            //获取文章标签
+            List<CommunityArticleTag> articleTags = communityArticleTagMapper
+                    .selectList(new QueryWrapper<CommunityArticleTag>()
+                            .eq("article_id", articleVo.getId()));
+            List<Long> tagIds = new ArrayList<>();
+            for (CommunityArticleTag articleTag : articleTags) {
+                tagIds.add(articleTag.getTagId());
+            }
 
-                //判断是否已收藏
-                CommunityArticleCollect collect = communityCollectMapper
-                        .selectOne(new QueryWrapper<CommunityArticleCollect>()
-                                .eq("user_id", userId)
-                                .eq("article_id", communityArticleCommentVo.getArticleId()));
-                articleVo.setCollect(!Objects.isNull(collect));
-
-                //判断是否已点赞
-                CommunityLike like = communityLikeMapper
-                        .selectOne(new QueryWrapper<CommunityLike>()
-                                .eq("user_id", userId)
-                                .eq("article_id", communityArticleCommentVo.getArticleId()));
-                articleVo.setLike(!Objects.isNull(like));
+            if (!tagIds.isEmpty()) {
+                List<CommunityTag> communityTags = communityTagMapper.selectBatchIds(tagIds);
+                articleVo.setTags(communityTags);
             }
+
         }
         return communityArticleVos;
     }
 
 
+    /**
+     * 发布文章
+     *
+     * @param communityArticle 文章信息
+     */
+    @Override
+    public void insertCommunityArticle(CommunityArticle communityArticle) {
+        Long userId = SecurityUtils.getLoginUser().getUserId();
+        //插入文章信息
+        communityArticle.setUserId(userId);
+        communityArticle.setCreateBy(userId);
+        communityArticle.setUpdateBy(userId);
+        communityArticle.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
+        communityArticle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
+        communityArticleMapper.insert(communityArticle);
+        //插入标签日志
+        List<CommunityTag> tags = communityArticle.getTags();
+        CommunityArticleTag tagLog = null;
+        for (CommunityTag tag : tags) {
+            tagLog = new CommunityArticleTag();
+            tagLog.setArticleId(communityArticle.getId());
+            tagLog.setTagId(tag.getId());
+            tagLog.setUpdateBy(userId);
+            tagLog.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
+            tagLog.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
+            tagLog.setCreateBy(userId);
+            articleTagMapper.insert(tagLog);
+        }
+
+        //插入图片日志
+        List<String> images = communityArticle.getImages();
+        CommunityArticleImages articleImages = null;
+        for (String image : images) {
+            articleImages = new CommunityArticleImages();
+            articleImages.setArticleId(communityArticle.getId());
+            articleImages.setImageUrl(image);
+            articleImages.setUpdateBy(userId);
+            articleImages.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
+            articleImages.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
+            articleImages.setCreateBy(userId);
+            communityArticleImagesMapper.insert(articleImages);
+        }
+    }
+
+
     /**
      * 发送评论
      *

+ 8 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/service/ICommunityArticleService.java

@@ -24,8 +24,16 @@ public interface ICommunityArticleService extends IService<CommunityArticle> {
      */
     List<CommunityArticleVo> selectCommunityArticleList(CommunityArticle communityArticle);
 
+    /**
+     * 发布文章
+     *
+     * @param communityArticle 文章信息
+     */
+    void insertCommunityArticle(CommunityArticle communityArticle);
+
     /**
      * 发送评论
+     *
      * @param communityArticleComment 评论信息
      */
     void sendComment(CommunityArticleComment communityArticleComment) throws ParseException;

+ 4 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/vo/CommunityArticleCommentVo.java

@@ -1,5 +1,7 @@
 package com.ruoyi.generator.vo;
 
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.ruoyi.common.core.domain.BaseEntity;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -18,6 +20,7 @@ import java.io.Serializable;
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
+@TableName("community_article_comment")
 public class CommunityArticleCommentVo extends BaseEntity implements Serializable {
 
     /**
@@ -25,6 +28,7 @@ public class CommunityArticleCommentVo extends BaseEntity implements Serializabl
     */
     @NotNull(message="[评论id]不能为空")
     @ApiModelProperty("评论id")
+    @TableId("id")
     private Long id;
     /**
     * 文章id

+ 4 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/vo/CommunityArticleVo.java

@@ -3,6 +3,7 @@ package com.ruoyi.generator.vo;
 import com.ruoyi.common.core.domain.BaseEntity;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.generator.domain.Community.CommunityArticleImages;
+import com.ruoyi.generator.domain.Community.CommunityTag;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -80,4 +81,7 @@ public class CommunityArticleVo extends BaseEntity implements Serializable {
 
     @ApiModelProperty("文章评论信息")
     private List<CommunityArticleCommentVo> comments;
+
+    @ApiModelProperty("文章标签")
+    private List<CommunityTag> tags;
 }

+ 48 - 51
ruoyi-generator/src/main/resources/mapper/community/ArticleMapper.xml

@@ -6,14 +6,14 @@
 
     <resultMap type="com.ruoyi.generator.vo.CommunityArticleVo" id="CommunityArticleVoResult">
         <id property="id" column="article_id"/>
-        <result property="userId" column="user_id"/>
-        <result property="title" column="title"/>
-        <result property="content" column="content"/>
-        <result property="classId" column="class_id"/>
-        <result property="createBy" column="create_by"/>
-        <result property="createTime" column="create_time"/>
-        <result property="updateBy" column="update_by"/>
-        <result property="updateTime" column="update_time"/>
+        <result property="userId" column="article_user_id"/>
+        <result property="title" column="article_title"/>
+        <result property="content" column="article_content"/>
+        <result property="classId" column="article_class_id"/>
+        <result property="createBy" column="article_create_by"/>
+        <result property="createTime" column="article_create_time"/>
+        <result property="updateBy" column="article_update_by"/>
+        <result property="updateTime" column="article_update_time"/>
         <result property="remark" column="remark"/>
         <collection property="imageList" javaType="java.util.List" resultMap="CommunityArticleImagesResult"/>
         <collection property="sysUsers" resultMap="SysUserResult"/>
@@ -22,13 +22,12 @@
 
     <resultMap type="CommunityArticleImages" id="CommunityArticleImagesResult">
         <id property="id" column="image_id"/>
-        <result property="articleId" column="article_id"/>
+        <result property="articleId" column="images_article_id"/>
         <result property="imageUrl" column="image_url"/>
-        <result property="createBy" column="create_by"/>
-        <result property="createTime" column="create_time"/>
-        <result property="updateBy" column="update_by"/>
-        <result property="updateTime" column="update_time"/>
-        <result property="remark" column="remark"/>
+        <result property="createBy" column="images_create_by"/>
+        <result property="createTime" column="images_create_time"/>
+        <result property="updateBy" column="images_update_by"/>
+        <result property="updateTime" column="images_update_time"/>
     </resultMap>
 
     <resultMap type="SysUser" id="SysUserResult">
@@ -51,14 +50,14 @@
 
     <resultMap type="com.ruoyi.generator.vo.CommunityArticleCommentVo" id="CommunityCommentsResult">
         <id property="id" column="comment_id"/>
-        <result property="articleId" column="article_id"/>
-        <result property="userId" column="user_id"/>
+        <result property="articleId" column="comment_article_id"/>
+        <result property="userId" column="comment_user_id"/>
         <result property="content" column="comment_content"/>
-        <result property="createBy" column="create_by"/>
-        <result property="createTime" column="create_time"/>
-        <result property="updateBy" column="update_by"/>
-        <result property="updateTime" column="update_time"/>
-        <result property="remark" column="remark"/>
+        <result property="createBy" column="comment_create_by"/>
+        <result property="createTime" column="comment_create_time"/>
+        <result property="updateBy" column="comment_update_by"/>
+        <result property="updateTime" column="comment_update_time"/>
+        <result property="remark" column="comment_remark"/>
     </resultMap>
 
     <resultMap id="CommunityCollectResult" type="CommunityArticleCollect">
@@ -97,50 +96,48 @@
     <select id="selectCommunityArticleList" parameterType="CommunityArticle" resultMap="CommunityArticleVoResult">
         select
         a.id as article_id,
-        a.user_id,
-        a.title,
-        a.is_comment,
-        a.content,
-        a.class_id,
-        a.create_by,
-        a.create_time,
-        a.update_by,
-        a.update_time,
-        a.remark,
+        a.user_id as article_user_id,
+        a.title as article_title,
+        a.is_comment as article_is_comment,
+        a.content as article_content,
+        a.class_id as article_class_id,
+        a.create_by as article_create_by,
+        a.create_time as article_create_time,
+        a.update_by as article_update_by,
+        a.update_time as article_update_time,
         b.id as image_id,
-        b.article_id,
-        b.image_url,
-        b.create_by,
-        b.create_time,
-        b.update_by,
-        b.update_time,
-        b.remark,
-        c.user_name,
-        c.nick_name,
-        c.email,
-        c.avatar,
+        b.article_id as images_article_id,
+        b.image_url as image_url,
+        b.create_by as images_create_by,
+        b.create_time as images_create_time,
+        b.update_by as images_update_by,
+        b.update_time as images_update_time,
+        c.user_name as user_name,
+        c.nick_name as nick_name,
+        c.email as email,
+        c.avatar as avatar,
         d.id as comment_id,
-        d.article_id,
-        d.user_id,
+        d.article_id as comment_article_id,
+        d.user_id as comment_user_id,
         d.content as comment_content,
-        d.create_by,
-        d.create_time,
-        d.update_by,
-        d.update_time
+        d.create_by as comment_create_by,
+        d.create_time as comment_create_time,
+        d.update_by as comment_update_by,
+        d.update_time as comment_update_time
         from
         community_article a
-        left join community_article_images b on a.id = b.id
+        left join community_article_images b on a.id = b.article_id
         left join sys_user c on a.user_id = c.user_id
         left join community_article_comment d on d.article_id = a.id
         <where>
             <if test="id != null and id != ''">
-                AND a.id like concat('%', #{id}, '%')
+                AND a.id = #{id}
             </if>
             <if test="title != null and title != ''">
                 AND a.title like concat('%', #{title}, '%')
             </if>
             <if test="classId != null and classId != ''">
-                AND a.class_id like concat('%', #{classId}, '%')
+                AND a.class_id = #{classId}
             </if>
         </where>
     </select>

+ 0 - 106
ruoyi-generator/src/main/resources/mapper/community/CommunityArticleImagesMapper.xml

@@ -1,106 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.ruoyi.generator.mapper.community.CommunityArticleImagesMapper">
-
-    <resultMap id="BaseResultMap" type="com.ruoyi.generator.domain.Community.CommunityArticleImages">
-            <id property="imageId" column="image_id" jdbcType="INTEGER"/>
-            <result property="articleId" column="article_id" jdbcType="INTEGER"/>
-            <result property="imageUrl" column="image_url" jdbcType="VARCHAR"/>
-            <result property="createBy" column="create_by" jdbcType="INTEGER"/>
-            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
-            <result property="updateBy" column="update_by" jdbcType="INTEGER"/>
-            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
-            <result property="remark" column="remark" jdbcType="VARCHAR"/>
-    </resultMap>
-
-    <sql id="Base_Column_List">
-        image_id,article_id,image_url,
-        create_by,create_time,update_by,
-        update_time,remark
-    </sql>
-
-    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-        select
-        <include refid="Base_Column_List" />
-        from community_article_images
-        where  image_id = #{imageId,jdbcType=INTEGER} 
-    </select>
-
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-        delete from community_article_images
-        where  image_id = #{imageId,jdbcType=INTEGER} 
-    </delete>
-    <insert id="insert" keyColumn="image_id" keyProperty="imageId" parameterType="com.ruoyi.generator.domain.Community.CommunityArticleImages" useGeneratedKeys="true">
-        insert into community_article_images
-        ( image_id,article_id,image_url
-        ,create_by,create_time,update_by
-        ,update_time,remark)
-        values (#{imageId,jdbcType=INTEGER},#{articleId,jdbcType=INTEGER},#{imageUrl,jdbcType=VARCHAR}
-        ,#{createBy,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateBy,jdbcType=INTEGER}
-        ,#{updateTime,jdbcType=TIMESTAMP},#{remark,jdbcType=VARCHAR})
-    </insert>
-    <insert id="insertSelective" keyColumn="image_id" keyProperty="imageId" parameterType="com.ruoyi.generator.domain.Community.CommunityArticleImages" useGeneratedKeys="true">
-        insert into community_article_images
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-                <if test="imageId != null">image_id,</if>
-                <if test="articleId != null">article_id,</if>
-                <if test="imageUrl != null">image_url,</if>
-                <if test="createBy != null">create_by,</if>
-                <if test="createTime != null">create_time,</if>
-                <if test="updateBy != null">update_by,</if>
-                <if test="updateTime != null">update_time,</if>
-                <if test="remark != null">remark,</if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-                <if test="imageId != null">#{imageId,jdbcType=INTEGER},</if>
-                <if test="articleId != null">#{articleId,jdbcType=INTEGER},</if>
-                <if test="imageUrl != null">#{imageUrl,jdbcType=VARCHAR},</if>
-                <if test="createBy != null">#{createBy,jdbcType=INTEGER},</if>
-                <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
-                <if test="updateBy != null">#{updateBy,jdbcType=INTEGER},</if>
-                <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
-                <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
-        </trim>
-    </insert>
-    <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.generator.domain.Community.CommunityArticleImages">
-        update community_article_images
-        <set>
-                <if test="articleId != null">
-                    article_id = #{articleId,jdbcType=INTEGER},
-                </if>
-                <if test="imageUrl != null">
-                    image_url = #{imageUrl,jdbcType=VARCHAR},
-                </if>
-                <if test="createBy != null">
-                    create_by = #{createBy,jdbcType=INTEGER},
-                </if>
-                <if test="createTime != null">
-                    create_time = #{createTime,jdbcType=TIMESTAMP},
-                </if>
-                <if test="updateBy != null">
-                    update_by = #{updateBy,jdbcType=INTEGER},
-                </if>
-                <if test="updateTime != null">
-                    update_time = #{updateTime,jdbcType=TIMESTAMP},
-                </if>
-                <if test="remark != null">
-                    remark = #{remark,jdbcType=VARCHAR},
-                </if>
-        </set>
-        where   image_id = #{imageId,jdbcType=INTEGER} 
-    </update>
-    <update id="updateByPrimaryKey" parameterType="com.ruoyi.generator.domain.Community.CommunityArticleImages">
-        update community_article_images
-        set 
-            article_id =  #{articleId,jdbcType=INTEGER},
-            image_url =  #{imageUrl,jdbcType=VARCHAR},
-            create_by =  #{createBy,jdbcType=INTEGER},
-            create_time =  #{createTime,jdbcType=TIMESTAMP},
-            update_by =  #{updateBy,jdbcType=INTEGER},
-            update_time =  #{updateTime,jdbcType=TIMESTAMP},
-            remark =  #{remark,jdbcType=VARCHAR}
-        where   image_id = #{imageId,jdbcType=INTEGER} 
-    </update>
-</mapper>