فهرست منبع

完善农技模块

jiuling 11 ماه پیش
والد
کامیت
c9cd6f2747

+ 3 - 3
ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/CorsConfig.java

@@ -10,10 +10,10 @@ import org.springframework.web.util.pattern.PathPatternParser;
 @Configuration
 public class CorsConfig {
 
-    @Bean
+    /*@Bean
     public CorsWebFilter corsWebFilter() {
         CorsConfiguration config = new CorsConfiguration();
-        config.addAllowedOrigin("http://localhost:9000"); // 只允许H5访问
+        config.addAllowedOriginPattern("http://localhost:9000");
         config.addAllowedHeader("*");
         config.addAllowedMethod("*");
         config.setAllowCredentials(true); // 允许带上cookie
@@ -21,5 +21,5 @@ public class CorsConfig {
         UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
         source.registerCorsConfiguration("/**", config);
         return new CorsWebFilter(source);
-    }
+    }*/
 }

+ 105 - 180
ruoyi-modules/ruoyi-uniapp/src/main/java/com/ruoyi/uniapp/controller/KnowledgeController.java

@@ -1,21 +1,18 @@
 package com.ruoyi.uniapp.controller;
 
 import java.util.List;
-import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
-import cn.hutool.core.util.ObjectUtil;
-import com.github.pagehelper.PageHelper;
 import com.ruoyi.common.core.web.page.TableDataInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.http.MediaType;
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.domain.AjaxResult;
-import com.ruoyi.common.security.utils.SecurityUtils;
-import com.ruoyi.uniapp.domain.KnowledgeArticle;
-import com.ruoyi.uniapp.domain.KnowledgeImage;
-import com.ruoyi.uniapp.domain.vo.KnowledgeArticleVO;
-import com.ruoyi.uniapp.service.IKnowledgeService;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.uniapp.domain.KnowledgeContent;
+import com.ruoyi.uniapp.service.IKnowledgeContentService;
 
 /**
  * 知识内容控制器
@@ -25,217 +22,145 @@ import com.ruoyi.uniapp.service.IKnowledgeService;
 public class KnowledgeController extends BaseController {
     
     @Autowired
-    private IKnowledgeService knowledgeService;
-    
+    private IKnowledgeContentService knowledgeContentService;
     /**
-     * 获取农技知识列表
+     * 查询知识内容列表
      */
-    @GetMapping("/tech")
-    public TableDataInfo getTechList(@RequestParam(required = false, defaultValue = "1") Integer pageNum,
-                                     @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
-        Integer userId = null;
-        try {
-            userId = SecurityUtils.getUserId().intValue();
-        } catch (Exception e) {
-            // 未登录或token无效
+    @GetMapping("/list")
+    public AjaxResult list(Integer page, Integer pageSize, String category)
+    {
+        startPage();
+        
+        KnowledgeContent knowledgeContent = new KnowledgeContent();
+        if (category != null) {
+            knowledgeContent.setContentCategory(category);
         }
-        PageHelper.startPage(ObjectUtil.defaultIfNull(pageNum, 1), ObjectUtil.defaultIfNull(pageSize, 10));
-
-        List<KnowledgeArticleVO> list = knowledgeService.getTechList(pageNum, pageSize, userId);
-
-        return getDataTable(list);
+        
+        List<KnowledgeContent> list = knowledgeContentService.selectKnowledgeContentList(knowledgeContent);
+        TableDataInfo dataTable = getDataTable(list);
+        
+        // 构造与前端一致的数据格式
+        Map<String, Object> data = new HashMap<>();
+        data.put("list", dataTable.getRows());
+        data.put("total", dataTable.getTotal());
+        
+        return AjaxResult.success(data);
     }
-    
+
     /**
-     * 获取政策解读列表
+     * 获取知识内容详情
      */
-    @GetMapping("/policy")
-    public TableDataInfo getPolicyList(@RequestParam(required = false, defaultValue = "1") Integer pageNum,
-                                    @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
-        Integer userId = null;
-        try {
-            userId = SecurityUtils.getUserId().intValue();
-        } catch (Exception e) {
-            // 未登录或token无效
-        }
-        PageHelper.startPage(ObjectUtil.defaultIfNull(pageNum, 1), ObjectUtil.defaultIfNull(pageSize, 10));
-
-        List<KnowledgeArticleVO> list = knowledgeService.getPolicyList(pageNum, pageSize, userId);
-        return getDataTable(list);
+    @GetMapping(value = "/detail")
+    public AjaxResult getInfo(Integer id, String type)
+    {
+        return AjaxResult.success(knowledgeContentService.selectKnowledgeContentById(id));
     }
     
     /**
-     * 获取知识详情
+     * 更新阅读量
      */
-    @GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public AjaxResult getArticleDetail(@PathVariable("id") Integer id) {
-        Integer userId = null;
-        try {
-            userId = SecurityUtils.getUserId().intValue();
-        } catch (Exception e) {
-            // 未登录或token无效
+    @PostMapping("/view")
+    public AjaxResult view(@RequestBody Map<String, Object> params)
+    {
+        Integer id = (Integer) params.get("id");
+        if (id == null) {
+            return AjaxResult.error("参数错误");
         }
         
-        KnowledgeArticleVO article = knowledgeService.getArticleDetail(id, userId);
-        if (article == null) {
-            return AjaxResult.error("文章不存在");
-        }
-        return AjaxResult.success(article);
+        knowledgeContentService.incrementViewCount(id);
+        return AjaxResult.success();
     }
     
     /**
-     * 获取文章相关图片
+     * 点赞内容
      */
-    @GetMapping("/images/{articleId}")
-    public AjaxResult getArticleImages(@PathVariable("articleId") Integer articleId) {
-        List<KnowledgeImage> images = knowledgeService.getArticleImages(articleId);
-        return AjaxResult.success(images);
-    }
-    
-    /**
-     * 获取轮播图
-     */
-    @GetMapping("/carousel")
-    public AjaxResult getCarouselImages() {
-        List<KnowledgeImage> carouselImages = knowledgeService.getCarouselImages();
-        return AjaxResult.success(carouselImages);
+    @PostMapping("/like")
+    public AjaxResult like(@RequestBody Map<String, Object> params)
+    {
+        Integer id = (Integer) params.get("id");
+        if (id == null) {
+            return AjaxResult.error("参数错误");
+        }
+        
+        // 实际业务中可能需要记录用户的点赞状态
+        return AjaxResult.success();
     }
     
     /**
-     * 创建文章
+     * 取消点赞
      */
-    @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
-    public AjaxResult createArticle(@RequestBody KnowledgeArticle article) {
-        try {
-            // 设置文章的创建者
-            Long userId = SecurityUtils.getUserId();
-            
-            // 设置发布日期和状态
-            article.setPublishDate(new Date());
-            if (article.getStatus() == null) {
-                article.setStatus(1); // 默认已发布状态
-            }
-            if (article.getViewCount() == null) {
-                article.setViewCount(0);
-            }
-            if (article.getLikeCount() == null) {
-                article.setLikeCount(0);
-            }
-            if (article.getIsRecommend() == null) {
-                article.setIsRecommend(0); // 默认不推荐
-            }
-            
-            // 确保HTML内容不被转义
-            // 使用原始内容,不做任何处理
-            
-            // 保存文章
-            int result = knowledgeService.insertKnowledgeArticle(article);
-            
-            if (result > 0) {
-                return AjaxResult.success("创建成功", article.getId());
-            } else {
-                return AjaxResult.error("创建失败");
-            }
-        } catch (Exception e) {
-            logger.error("创建文章失败: ", e);
-            return AjaxResult.error("创建文章失败: " + e.getMessage());
+    @PostMapping("/unlike")
+    public AjaxResult unlike(@RequestBody Map<String, Object> params)
+    {
+        Integer id = (Integer) params.get("id");
+        if (id == null) {
+            return AjaxResult.error("参数错误");
         }
+        
+        // 实际业务中可能需要删除用户的点赞记录
+        return AjaxResult.success();
     }
     
     /**
-     * 更新文章
+     * 收藏内容
      */
-    @PutMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
-    public AjaxResult updateArticle(@RequestBody KnowledgeArticle article) {
-        try {
-            if (article.getId() == null) {
-                return AjaxResult.error("文章ID不能为空");
-            }
-            
-            // 验证文章是否存在
-            KnowledgeArticle existingArticle = knowledgeService.selectKnowledgeArticleById(article.getId());
-            if (existingArticle == null) {
-                return AjaxResult.error("文章不存在");
-            }
-            
-            // 确保HTML内容不被转义
-            // 使用原始内容,不做任何处理
-            
-            // 更新文章
-            int result = knowledgeService.updateKnowledgeArticle(article);
-            
-            if (result > 0) {
-                return AjaxResult.success("更新成功");
-            } else {
-                return AjaxResult.error("更新失败");
-            }
-        } catch (Exception e) {
-            logger.error("更新文章失败: ", e);
-            return AjaxResult.error("更新文章失败: " + e.getMessage());
+    @PostMapping("/collect")
+    public AjaxResult collect(@RequestBody Map<String, Object> params)
+    {
+        Integer id = (Integer) params.get("id");
+        if (id == null) {
+            return AjaxResult.error("参数错误");
         }
+        
+        // 实际业务中可能需要记录用户的收藏状态
+        return AjaxResult.success();
     }
     
     /**
-     * 点赞文章
+     * 取消收藏
      */
-    @PostMapping("/like/{id}")
-    public AjaxResult likeArticle(@PathVariable("id") Integer id) {
-        Integer userId;
-        try {
-            userId = SecurityUtils.getUserId().intValue();
-        } catch (Exception e) {
-            return AjaxResult.error("请先登录");
+    @PostMapping("/uncollect")
+    public AjaxResult uncollect(@RequestBody Map<String, Object> params)
+    {
+        Integer id = (Integer) params.get("id");
+        if (id == null) {
+            return AjaxResult.error("参数错误");
         }
         
-        int result = knowledgeService.likeArticle(id, userId, true);
-        return AjaxResult.success("点赞成功", result);
+        // 实际业务中可能需要删除用户的收藏记录
+        return AjaxResult.success();
     }
-    
+
     /**
-     * 取消点赞
+     * 新增知识内容
      */
-    @DeleteMapping("/like/{id}")
-    public AjaxResult cancelLikeArticle(@PathVariable("id") Integer id) {
-        Integer userId;
-        try {
-            userId = SecurityUtils.getUserId().intValue();
-        } catch (Exception e) {
-            return AjaxResult.error("请先登录");
-        }
-        
-        int result = knowledgeService.likeArticle(id, userId, false);
-        return AjaxResult.success("取消点赞成功", result);
+//    @PreAuthorize(hasPermi = "uniapp:knowledge:add")
+    @Log(title = "知识内容", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody KnowledgeContent knowledgeContent)
+    {
+        return toAjax(knowledgeContentService.insertKnowledgeContent(knowledgeContent));
     }
-    
+
     /**
-     * 收藏文章
+     * 修改知识内容
      */
-    @PostMapping("/favorite/{id}")
-    public AjaxResult favoriteArticle(@PathVariable("id") Integer id) {
-        Integer userId;
-        try {
-            userId = SecurityUtils.getUserId().intValue();
-        } catch (Exception e) {
-            return AjaxResult.error("请先登录");
-        }
-        
-        int result = knowledgeService.favoriteArticle(id, userId, true);
-        return AjaxResult.success("收藏成功", result);
+//    @PreAuthorize(hasPermi = "uniapp:knowledge:edit")
+    @Log(title = "知识内容", businessType = BusinessType.UPDATE)
+    @PostMapping("/update")
+    public AjaxResult edit(@RequestBody KnowledgeContent knowledgeContent)
+    {
+        return toAjax(knowledgeContentService.updateKnowledgeContent(knowledgeContent));
     }
-    
+
     /**
-     * 取消收藏
+     * 删除知识内容
      */
-    @DeleteMapping("/favorite/{id}")
-    public AjaxResult cancelFavoriteArticle(@PathVariable("id") Integer id) {
-        Integer userId;
-        try {
-            userId = SecurityUtils.getUserId().intValue();
-        } catch (Exception e) {
-            return AjaxResult.error("请先登录");
-        }
-        
-        int result = knowledgeService.favoriteArticle(id, userId, false);
-        return AjaxResult.success("取消收藏成功", result);
+//    @PreAuthorize(hasPermi = "uniapp:knowledge:remove")
+    @Log(title = "知识内容", businessType = BusinessType.DELETE)
+    @PostMapping("/delete/{ids}")
+    public AjaxResult remove(@PathVariable Integer[] ids)
+    {
+        return toAjax(knowledgeContentService.deleteKnowledgeContentByIds(ids));
     }
 } 

+ 0 - 251
ruoyi-modules/ruoyi-uniapp/src/main/java/com/ruoyi/uniapp/domain/KnowledgeArticle.java

@@ -1,251 +0,0 @@
-package com.ruoyi.uniapp.domain;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.ruoyi.common.core.annotation.Excel;
-
-/**
- * 知识文章对象 knowledge_article
- */
-public class KnowledgeArticle implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /** ID */
-    private Integer id;
-
-    /** 标题 */
-    @Excel(name = "标题")
-    private String title;
-
-    /** 简短描述 */
-    @Excel(name = "简短描述")
-    private String description;
-
-    /** 内容(HTML格式) */
-    private String content;
-
-    /** 分类: tech-农技知识, policy-政策解读 */
-    @Excel(name = "分类", readConverterExp = "tech=农技知识,policy=政策解读")
-    private String category;
-
-    /** 缩略图 */
-    private String thumbnail;
-
-    /** 内容类型: article-文章, video-视频 */
-    @Excel(name = "内容类型", readConverterExp = "article=文章,video=视频")
-    @JsonProperty("contentType")
-    private String contentType;
-
-    /** 视频URL,当content_type为video时使用 */
-    @JsonProperty("videoUrl")
-    private String videoUrl;
-
-    /** 视频时长,如"15:32" */
-    @JsonProperty("videoDuration")
-    private String videoDuration;
-
-    /** 来源,如"农业技术研究院" */
-    private String source;
-
-    /** 标签,多个标签用逗号分隔 */
-    private String tags;
-
-    /** 发布日期 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "发布日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
-    @JsonProperty("publishDate")
-    private Date publishDate;
-
-    /** 浏览次数 */
-    @Excel(name = "浏览次数")
-    @JsonProperty("viewCount")
-    private Integer viewCount;
-
-    /** 点赞次数 */
-    @Excel(name = "点赞次数")
-    @JsonProperty("likeCount")
-    private Integer likeCount;
-
-    /** 是否推荐: 0-否,1-是 */
-    @Excel(name = "是否推荐", readConverterExp = "0=否,1=是")
-    @JsonProperty("isRecommend")
-    private Integer isRecommend;
-
-    /** 状态: 0-草稿,1-已发布 */
-    @Excel(name = "状态", readConverterExp = "0=草稿,1=已发布")
-    private Integer status;
-
-    /** 创建时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonProperty("createTime")
-    private Date createTime;
-
-    /** 更新时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonProperty("updateTime")
-    private Date updateTime;
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public String getContent() {
-        return content;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-
-    public String getCategory() {
-        return category;
-    }
-
-    public void setCategory(String category) {
-        this.category = category;
-    }
-
-    public String getThumbnail() {
-        return thumbnail;
-    }
-
-    public void setThumbnail(String thumbnail) {
-        this.thumbnail = thumbnail;
-    }
-
-    public String getContentType() {
-        return contentType;
-    }
-
-    public void setContentType(String contentType) {
-        this.contentType = contentType;
-    }
-
-    public String getVideoUrl() {
-        return videoUrl;
-    }
-
-    public void setVideoUrl(String videoUrl) {
-        this.videoUrl = videoUrl;
-    }
-
-    public String getVideoDuration() {
-        return videoDuration;
-    }
-
-    public void setVideoDuration(String videoDuration) {
-        this.videoDuration = videoDuration;
-    }
-
-    public String getSource() {
-        return source;
-    }
-
-    public void setSource(String source) {
-        this.source = source;
-    }
-
-    public String getTags() {
-        return tags;
-    }
-
-    public void setTags(String tags) {
-        this.tags = tags;
-    }
-
-    public Date getPublishDate() {
-        return publishDate;
-    }
-
-    public void setPublishDate(Date publishDate) {
-        this.publishDate = publishDate;
-    }
-
-    public Integer getViewCount() {
-        return viewCount;
-    }
-
-    public void setViewCount(Integer viewCount) {
-        this.viewCount = viewCount;
-    }
-
-    public Integer getLikeCount() {
-        return likeCount;
-    }
-
-    public void setLikeCount(Integer likeCount) {
-        this.likeCount = likeCount;
-    }
-
-    public Integer getIsRecommend() {
-        return isRecommend;
-    }
-
-    public void setIsRecommend(Integer isRecommend) {
-        this.isRecommend = isRecommend;
-    }
-
-    public Integer getStatus() {
-        return status;
-    }
-
-    public void setStatus(Integer status) {
-        this.status = status;
-    }
-
-    public Date getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
-    }
-
-    public Date getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(Date updateTime) {
-        this.updateTime = updateTime;
-    }
-
-    @Override
-    public String toString() {
-        return "KnowledgeArticle{" +
-                "id=" + id +
-                ", title='" + title + '\'' +
-                ", description='" + description + '\'' +
-                ", category='" + category + '\'' +
-                ", thumbnail='" + thumbnail + '\'' +
-                ", contentType='" + contentType + '\'' +
-                ", source='" + source + '\'' +
-                ", publishDate=" + publishDate +
-                ", viewCount=" + viewCount +
-                ", likeCount=" + likeCount +
-                ", status=" + status +
-                '}';
-    }
-} 

+ 82 - 0
ruoyi-modules/ruoyi-uniapp/src/main/java/com/ruoyi/uniapp/domain/KnowledgeContent.java

@@ -0,0 +1,82 @@
+package com.ruoyi.uniapp.domain;
+
+import java.util.Date;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * 知识内容对象 knowledge_content
+ *
+ * @author ruoyi
+ */
+@Data
+public class KnowledgeContent extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** ID */
+    private Integer id;
+
+    /** 标题 */
+    @Excel(name = "标题")
+    private String title;
+
+    /** 描述 */
+    @Excel(name = "描述")
+    private String description;
+
+    /** 内容类型:文章或视频 */
+    private String contentType;
+
+    /** 内容分类:农技知识或政策解读 */
+    private String contentCategory;
+
+    /** 封面图片 */
+    @Excel(name = "封面图片")
+    private String imageUrl;
+
+    /** 来源 */
+    @Excel(name = "来源")
+    private String source;
+
+    /** 阅读量 */
+    @Excel(name = "阅读量")
+    private Integer viewCount;
+
+    /** 视频链接 */
+    @Excel(name = "视频链接")
+    private String videoUrl;
+
+    /** 视频时长 */
+    @Excel(name = "视频时长")
+    private String duration;
+
+    /** 文章内容 */
+    private String articleContent;
+
+    /** 作者 */
+    @Excel(name = "作者")
+    private String author;
+
+    /** 标签 */
+    @Excel(name = "标签")
+    private String tags;
+
+    /** 发布时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date publishDate;
+
+    /** 状态:1启用,0禁用 */
+    @Excel(name = "状态", readConverterExp = "1=启用,0=禁用")
+    private Integer status;
+
+    /*
+    * 文章关联的图片
+    * */
+    private List<KnowledgeImage> knowledgeImage;
+}

+ 0 - 200
ruoyi-modules/ruoyi-uniapp/src/main/java/com/ruoyi/uniapp/domain/vo/KnowledgeArticleVO.java

@@ -1,200 +0,0 @@
-package com.ruoyi.uniapp.domain.vo;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.ruoyi.uniapp.domain.KnowledgeImage;
-
-/**
- * 知识文章VO对象,用于前端展示
- */
-public class KnowledgeArticleVO implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    /** ID */
-    private Integer id;
-
-    /** 标题 */
-    private String title;
-
-    /** 简短描述 */
-    private String description;
-
-    /** 内容(HTML格式) */
-    private String content;
-
-    /** 分类: tech-农技知识, policy-政策解读 */
-    private String type;
-
-    /** 缩略图 */
-    private String image;
-
-    /** 内容类型: article-文章, video-视频 */
-    @JsonProperty("contentType")
-    private String contentType;
-
-    /** 视频URL,当content_type为video时使用 */
-    @JsonProperty("videoUrl")
-    private String videoUrl;
-
-    /** 视频时长,如"15:32" */
-    private String duration;
-
-    /** 来源,如"农业技术研究院" */
-    private String source;
-
-    /** 发布时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonProperty("publishTime")
-    private Date publishTime;
-
-    /** 浏览次数 */
-    @JsonProperty("viewCount")
-    private Integer viewCount;
-
-    /** 点赞次数 */
-    @JsonProperty("likeCount")
-    private Integer likeCount;
-
-    /** 是否已点赞: 0-否,1-是 */
-    @JsonProperty("isLiked")
-    private Integer isLiked;
-
-    /** 是否已收藏: 0-否,1-是 */
-    @JsonProperty("isFavorite")
-    private Integer isFavorite;
-    
-    /** 相关图片列表 */
-    private List<KnowledgeImage> images;
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public String getContent() {
-        return content;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public String getImage() {
-        return image;
-    }
-
-    public void setImage(String image) {
-        this.image = image;
-    }
-
-    public String getContentType() {
-        return contentType;
-    }
-
-    public void setContentType(String contentType) {
-        this.contentType = contentType;
-    }
-
-    public String getVideoUrl() {
-        return videoUrl;
-    }
-
-    public void setVideoUrl(String videoUrl) {
-        this.videoUrl = videoUrl;
-    }
-
-    public String getDuration() {
-        return duration;
-    }
-
-    public void setDuration(String duration) {
-        this.duration = duration;
-    }
-
-    public String getSource() {
-        return source;
-    }
-
-    public void setSource(String source) {
-        this.source = source;
-    }
-
-    public Date getPublishTime() {
-        return publishTime;
-    }
-
-    public void setPublishTime(Date publishTime) {
-        this.publishTime = publishTime;
-    }
-
-    public Integer getViewCount() {
-        return viewCount;
-    }
-
-    public void setViewCount(Integer viewCount) {
-        this.viewCount = viewCount;
-    }
-
-    public Integer getLikeCount() {
-        return likeCount;
-    }
-
-    public void setLikeCount(Integer likeCount) {
-        this.likeCount = likeCount;
-    }
-
-    public Integer getIsLiked() {
-        return isLiked;
-    }
-
-    public void setIsLiked(Integer isLiked) {
-        this.isLiked = isLiked;
-    }
-
-    public Integer getIsFavorite() {
-        return isFavorite;
-    }
-
-    public void setIsFavorite(Integer isFavorite) {
-        this.isFavorite = isFavorite;
-    }
-
-    public List<KnowledgeImage> getImages() {
-        return images;
-    }
-
-    public void setImages(List<KnowledgeImage> images) {
-        this.images = images;
-    }
-} 

+ 0 - 79
ruoyi-modules/ruoyi-uniapp/src/main/java/com/ruoyi/uniapp/mapper/KnowledgeArticleMapper.java

@@ -1,79 +0,0 @@
-package com.ruoyi.uniapp.mapper;
-
-import java.util.List;
-import org.apache.ibatis.annotations.Param;
-import com.ruoyi.uniapp.domain.KnowledgeArticle;
-
-/**
- * 知识文章Mapper接口
- */
-public interface KnowledgeArticleMapper {
-    /**
-     * 查询知识文章
-     * 
-     * @param id 知识文章主键
-     * @return 知识文章
-     */
-    public KnowledgeArticle selectKnowledgeArticleById(Integer id);
-
-    /**
-     * 查询知识文章列表
-     * 
-     * @param knowledgeArticle 知识文章
-     * @return 知识文章集合
-     */
-    public List<KnowledgeArticle> selectKnowledgeArticleList(KnowledgeArticle knowledgeArticle);
-    
-    /**
-     * 根据分类查询文章列表
-     * 
-     * @param category 分类
-     * @param pageNum 页码
-     * @param pageSize 每页条数
-     * @return 知识文章集合
-     */
-    public List<KnowledgeArticle> selectKnowledgeArticlesByCategory(@Param("category") String category, 
-                                                                  @Param("pageNum") Integer pageNum, 
-                                                                  @Param("pageSize") Integer pageSize);
-    
-    /**
-     * 新增知识文章
-     * 
-     * @param knowledgeArticle 知识文章
-     * @return 结果
-     */
-    public int insertKnowledgeArticle(KnowledgeArticle knowledgeArticle);
-    
-    /**
-     * 修改知识文章
-     * 
-     * @param knowledgeArticle 知识文章
-     * @return 结果
-     */
-    public int updateKnowledgeArticle(KnowledgeArticle knowledgeArticle);
-    
-    /**
-     * 删除知识文章
-     * 
-     * @param id 知识文章主键
-     * @return 结果
-     */
-    public int deleteKnowledgeArticleById(Integer id);
-    
-    /**
-     * 更新阅读数
-     * 
-     * @param id 文章ID
-     * @return 结果
-     */
-    public int updateViewCount(Integer id);
-    
-    /**
-     * 更新点赞数
-     * 
-     * @param id 文章ID
-     * @param count 增加的数量,可为负数
-     * @return 结果
-     */
-    public int updateLikeCount(@Param("id") Integer id, @Param("count") Integer count);
-} 

+ 68 - 0
ruoyi-modules/ruoyi-uniapp/src/main/java/com/ruoyi/uniapp/mapper/KnowledgeContentMapper.java

@@ -0,0 +1,68 @@
+package com.ruoyi.uniapp.mapper;
+
+import java.util.List;
+import com.ruoyi.uniapp.domain.KnowledgeContent;
+
+/**
+ * 知识内容Mapper接口
+ * 
+ * @author ruoyi
+ */
+public interface KnowledgeContentMapper 
+{
+    /**
+     * 查询知识内容
+     * 
+     * @param id 知识内容主键
+     * @return 知识内容
+     */
+    public KnowledgeContent selectKnowledgeContentById(Integer id);
+
+    /**
+     * 查询知识内容列表
+     * 
+     * @param knowledgeContent 知识内容
+     * @return 知识内容集合
+     */
+    public List<KnowledgeContent> selectKnowledgeContentList(KnowledgeContent knowledgeContent);
+
+    /**
+     * 新增知识内容
+     * 
+     * @param knowledgeContent 知识内容
+     * @return 结果
+     */
+    public int insertKnowledgeContent(KnowledgeContent knowledgeContent);
+
+    /**
+     * 修改知识内容
+     * 
+     * @param knowledgeContent 知识内容
+     * @return 结果
+     */
+    public int updateKnowledgeContent(KnowledgeContent knowledgeContent);
+
+    /**
+     * 删除知识内容
+     * 
+     * @param id 知识内容主键
+     * @return 结果
+     */
+    public int deleteKnowledgeContentById(Integer id);
+
+    /**
+     * 批量删除知识内容
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteKnowledgeContentByIds(Integer[] ids);
+    
+    /**
+     * 更新阅读量
+     * 
+     * @param id 知识内容主键
+     * @return 结果
+     */
+    public int incrementViewCount(Integer id);
+}

+ 68 - 0
ruoyi-modules/ruoyi-uniapp/src/main/java/com/ruoyi/uniapp/service/IKnowledgeContentService.java

@@ -0,0 +1,68 @@
+package com.ruoyi.uniapp.service;
+
+import java.util.List;
+import com.ruoyi.uniapp.domain.KnowledgeContent;
+
+/**
+ * 知识内容Service接口
+ * 
+ * @author ruoyi
+ */
+public interface IKnowledgeContentService 
+{
+    /**
+     * 查询知识内容
+     * 
+     * @param id 知识内容主键
+     * @return 知识内容
+     */
+    public KnowledgeContent selectKnowledgeContentById(Integer id);
+
+    /**
+     * 查询知识内容列表
+     * 
+     * @param knowledgeContent 知识内容
+     * @return 知识内容集合
+     */
+    public List<KnowledgeContent> selectKnowledgeContentList(KnowledgeContent knowledgeContent);
+
+    /**
+     * 新增知识内容
+     * 
+     * @param knowledgeContent 知识内容
+     * @return 结果
+     */
+    public int insertKnowledgeContent(KnowledgeContent knowledgeContent);
+
+    /**
+     * 修改知识内容
+     * 
+     * @param knowledgeContent 知识内容
+     * @return 结果
+     */
+    public int updateKnowledgeContent(KnowledgeContent knowledgeContent);
+
+    /**
+     * 批量删除知识内容
+     * 
+     * @param ids 需要删除的知识内容主键集合
+     * @return 结果
+     */
+    public int deleteKnowledgeContentByIds(Integer[] ids);
+
+    /**
+     * 删除知识内容信息
+     * 
+     * @param id 知识内容主键
+     * @return 结果
+     */
+    public int deleteKnowledgeContentById(Integer id);
+    
+    /**
+     * 更新阅读量
+     * 
+     * @param id 知识内容主键
+     * @return 结果
+     */
+    public int incrementViewCount(Integer id);
+} 

+ 0 - 116
ruoyi-modules/ruoyi-uniapp/src/main/java/com/ruoyi/uniapp/service/IKnowledgeService.java

@@ -1,116 +0,0 @@
-package com.ruoyi.uniapp.service;
-
-import java.util.List;
-import com.ruoyi.uniapp.domain.vo.KnowledgeArticleVO;
-import com.ruoyi.uniapp.domain.KnowledgeArticle;
-import com.ruoyi.uniapp.domain.KnowledgeImage;
-
-/**
- * 知识服务接口
- */
-public interface IKnowledgeService {
-    /**
-     * 获取农技知识列表
-     * 
-     * @param pageNum 页码
-     * @param pageSize 每页条数
-     * @param userId 用户ID
-     * @return 农技知识列表
-     */
-    public List<KnowledgeArticleVO> getTechList(Integer pageNum, Integer pageSize, Integer userId);
-    
-    /**
-     * 获取政策解读列表
-     * 
-     * @param pageNum 页码
-     * @param pageSize 每页条数
-     * @param userId 用户ID
-     * @return 政策解读列表
-     */
-    public List<KnowledgeArticleVO> getPolicyList(Integer pageNum, Integer pageSize, Integer userId);
-    
-    /**
-     * 获取知识文章详情
-     * 
-     * @param id 文章ID
-     * @param userId 用户ID
-     * @return 文章详情
-     */
-    public KnowledgeArticleVO getArticleDetail(Integer id, Integer userId);
-    
-    /**
-     * 获取文章相关图片
-     * 
-     * @param articleId 文章ID
-     * @return 图片列表
-     */
-    public List<KnowledgeImage> getArticleImages(Integer articleId);
-    
-    /**
-     * 获取轮播图
-     * 
-     * @return 轮播图列表
-     */
-    public List<KnowledgeImage> getCarouselImages();
-    
-    /**
-     * 新增知识文章
-     * 
-     * @param knowledgeArticle 知识文章
-     * @return 结果
-     */
-    public int insertKnowledgeArticle(KnowledgeArticle knowledgeArticle);
-    
-    /**
-     * 修改知识文章
-     * 
-     * @param knowledgeArticle 知识文章
-     * @return 结果
-     */
-    public int updateKnowledgeArticle(KnowledgeArticle knowledgeArticle);
-    
-    /**
-     * 删除知识文章
-     * 
-     * @param id 知识文章主键
-     * @return 结果
-     */
-    public int deleteKnowledgeArticleById(Integer id);
-    
-    /**
-     * 记录用户浏览文章
-     * 
-     * @param articleId 文章ID
-     * @param userId 用户ID
-     * @return 结果
-     */
-    public int recordUserView(Integer articleId, Integer userId);
-    
-    /**
-     * 用户点赞/取消点赞文章
-     * 
-     * @param articleId 文章ID
-     * @param userId 用户ID
-     * @param isLike true-点赞,false-取消点赞
-     * @return 结果
-     */
-    public int likeArticle(Integer articleId, Integer userId, boolean isLike);
-    
-    /**
-     * 用户收藏/取消收藏文章
-     * 
-     * @param articleId 文章ID
-     * @param userId 用户ID
-     * @param isFavorite true-收藏,false-取消收藏
-     * @return 结果
-     */
-    public int favoriteArticle(Integer articleId, Integer userId, boolean isFavorite);
-    
-    /**
-     * 根据ID查询知识文章
-     * 
-     * @param id 文章ID
-     * @return 知识文章
-     */
-    public KnowledgeArticle selectKnowledgeArticleById(Integer id);
-} 

+ 104 - 0
ruoyi-modules/ruoyi-uniapp/src/main/java/com/ruoyi/uniapp/service/impl/KnowledgeContentServiceImpl.java

@@ -0,0 +1,104 @@
+package com.ruoyi.uniapp.service.impl;
+
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.uniapp.mapper.KnowledgeContentMapper;
+import com.ruoyi.uniapp.domain.KnowledgeContent;
+import com.ruoyi.uniapp.service.IKnowledgeContentService;
+
+/**
+ * 知识内容Service业务层处理
+ * 
+ * @author ruoyi
+ */
+@Service
+public class KnowledgeContentServiceImpl implements IKnowledgeContentService 
+{
+    @Autowired
+    private KnowledgeContentMapper knowledgeContentMapper;
+
+    /**
+     * 查询知识内容
+     * 
+     * @param id 知识内容主键
+     * @return 知识内容
+     */
+    @Override
+    public KnowledgeContent selectKnowledgeContentById(Integer id)
+    {
+        return knowledgeContentMapper.selectKnowledgeContentById(id);
+    }
+
+    /**
+     * 查询知识内容列表
+     * 
+     * @param knowledgeContent 知识内容
+     * @return 知识内容
+     */
+    @Override
+    public List<KnowledgeContent> selectKnowledgeContentList(KnowledgeContent knowledgeContent)
+    {
+        return knowledgeContentMapper.selectKnowledgeContentList(knowledgeContent);
+    }
+
+    /**
+     * 新增知识内容
+     * 
+     * @param knowledgeContent 知识内容
+     * @return 结果
+     */
+    @Override
+    public int insertKnowledgeContent(KnowledgeContent knowledgeContent)
+    {
+        return knowledgeContentMapper.insertKnowledgeContent(knowledgeContent);
+    }
+
+    /**
+     * 修改知识内容
+     * 
+     * @param knowledgeContent 知识内容
+     * @return 结果
+     */
+    @Override
+    public int updateKnowledgeContent(KnowledgeContent knowledgeContent)
+    {
+        return knowledgeContentMapper.updateKnowledgeContent(knowledgeContent);
+    }
+
+    /**
+     * 批量删除知识内容
+     * 
+     * @param ids 需要删除的知识内容主键
+     * @return 结果
+     */
+    @Override
+    public int deleteKnowledgeContentByIds(Integer[] ids)
+    {
+        return knowledgeContentMapper.deleteKnowledgeContentByIds(ids);
+    }
+
+    /**
+     * 删除知识内容信息
+     * 
+     * @param id 知识内容主键
+     * @return 结果
+     */
+    @Override
+    public int deleteKnowledgeContentById(Integer id)
+    {
+        return knowledgeContentMapper.deleteKnowledgeContentById(id);
+    }
+    
+    /**
+     * 更新阅读量
+     * 
+     * @param id 知识内容主键
+     * @return 结果
+     */
+    @Override
+    public int incrementViewCount(Integer id)
+    {
+        return knowledgeContentMapper.incrementViewCount(id);
+    }
+} 

+ 0 - 316
ruoyi-modules/ruoyi-uniapp/src/main/java/com/ruoyi/uniapp/service/impl/KnowledgeServiceImpl.java

@@ -1,316 +0,0 @@
-package com.ruoyi.uniapp.service.impl;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import cn.hutool.core.util.ObjectUtil;
-import com.github.pagehelper.PageHelper;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.ruoyi.uniapp.mapper.KnowledgeArticleMapper;
-import com.ruoyi.uniapp.mapper.KnowledgeImageMapper;
-import com.ruoyi.uniapp.mapper.UserInteractionMapper;
-import com.ruoyi.uniapp.domain.KnowledgeArticle;
-import com.ruoyi.uniapp.domain.KnowledgeImage;
-import com.ruoyi.uniapp.domain.UserInteraction;
-import com.ruoyi.uniapp.domain.vo.KnowledgeArticleVO;
-import com.ruoyi.uniapp.service.IKnowledgeService;
-
-/**
- * 知识服务实现
- */
-@Service
-public class KnowledgeServiceImpl implements IKnowledgeService {
-
-    @Autowired
-    private KnowledgeArticleMapper knowledgeArticleMapper;
-    
-    @Autowired
-    private KnowledgeImageMapper knowledgeImageMapper;
-    
-    @Autowired
-    private UserInteractionMapper userInteractionMapper;
-
-    /**
-     * 获取农技知识列表
-     */
-    @Override
-    public List<KnowledgeArticleVO> getTechList(Integer pageNum, Integer pageSize, Integer userId) {
-        // 查询农技知识列表
-        List<KnowledgeArticle> articles = knowledgeArticleMapper.selectKnowledgeArticlesByCategory("tech", pageNum, pageSize);
-        
-        // 转换为前端VO对象
-        return convertToVOList(articles, userId);
-    }
-
-    /**
-     * 获取政策解读列表
-     */
-    @Override
-    public List<KnowledgeArticleVO> getPolicyList(Integer pageNum, Integer pageSize, Integer userId) {
-//        pageNum = (pageNum - 1) * pageSize;
-        // 查询政策解读列表
-        List<KnowledgeArticle> articles = knowledgeArticleMapper.selectKnowledgeArticlesByCategory("policy", pageNum, pageSize);
-        
-        // 转换为前端VO对象
-        return convertToVOList(articles, userId);
-    }
-
-    /**
-     * 获取文章详情
-     */
-    @Override
-    public KnowledgeArticleVO getArticleDetail(Integer id, Integer userId) {
-        // 查询文章详情
-        KnowledgeArticle article = knowledgeArticleMapper.selectKnowledgeArticleById(id);
-        if (article == null) {
-            return null;
-        }
-        
-        // 增加浏览次数
-        knowledgeArticleMapper.updateViewCount(id);
-        
-        // 如果用户已登录,记录用户浏览记录
-        if (userId != null) {
-            recordUserView(id, userId);
-        }
-        
-        // 转换为前端VO对象
-        KnowledgeArticleVO vo = convertToVO(article, userId);
-        
-        // 查询文章相关图片
-        List<KnowledgeImage> images = knowledgeImageMapper.selectKnowledgeImagesByArticleId(id, "content");
-        vo.setImages(images);
-        
-        return vo;
-    }
-
-    /**
-     * 获取文章相关图片
-     */
-    @Override
-    public List<KnowledgeImage> getArticleImages(Integer articleId) {
-        return knowledgeImageMapper.selectKnowledgeImagesByArticleId(articleId, "content");
-    }
-
-    /**
-     * 获取轮播图
-     */
-    @Override
-    public List<KnowledgeImage> getCarouselImages() {
-        return knowledgeImageMapper.selectKnowledgeImagesByType("carousel", 5);
-    }
-    
-    /**
-     * 新增知识文章
-     */
-    @Override
-    public int insertKnowledgeArticle(KnowledgeArticle knowledgeArticle) {
-        return knowledgeArticleMapper.insertKnowledgeArticle(knowledgeArticle);
-    }
-    
-    /**
-     * 修改知识文章
-     */
-    @Override
-    public int updateKnowledgeArticle(KnowledgeArticle knowledgeArticle) {
-        return knowledgeArticleMapper.updateKnowledgeArticle(knowledgeArticle);
-    }
-    
-    /**
-     * 删除知识文章
-     */
-    @Override
-    public int deleteKnowledgeArticleById(Integer id) {
-        return knowledgeArticleMapper.deleteKnowledgeArticleById(id);
-    }
-
-    /**
-     * 记录用户浏览文章
-     */
-    @Override
-    public int recordUserView(Integer articleId, Integer userId) {
-        if (userId == null || articleId == null) {
-            return 0;
-        }
-        
-        // 检查是否已有记录
-        UserInteraction existRecord = userInteractionMapper.selectUserInteraction(userId, articleId, "view");
-        if (existRecord != null) {
-            // 更新记录时间
-            existRecord.setCreateTime(new Date());
-            return userInteractionMapper.updateUserInteraction(existRecord);
-        }
-        
-        // 创建新记录
-        UserInteraction record = new UserInteraction();
-        record.setUserId(userId);
-        record.setArticleId(articleId);
-        record.setType("view");
-        record.setCreateTime(new Date());
-        return userInteractionMapper.insertUserInteraction(record);
-    }
-
-    /**
-     * 用户点赞/取消点赞文章
-     */
-    @Override
-    @Transactional
-    public int likeArticle(Integer articleId, Integer userId, boolean isLike) {
-        if (userId == null || articleId == null) {
-            return 0;
-        }
-        
-        // 检查文章是否存在
-        KnowledgeArticle article = knowledgeArticleMapper.selectKnowledgeArticleById(articleId);
-        if (article == null) {
-            return 0;
-        }
-        
-        // 查询是否已点赞
-        UserInteraction existRecord = userInteractionMapper.selectUserInteraction(userId, articleId, "like");
-        
-        if (isLike) {
-            // 点赞操作
-            if (existRecord != null) {
-                // 已点赞,无需操作
-                return 1;
-            }
-            
-            // 创建点赞记录
-            UserInteraction record = new UserInteraction();
-            record.setUserId(userId);
-            record.setArticleId(articleId);
-            record.setType("like");
-            record.setCreateTime(new Date());
-            int result = userInteractionMapper.insertUserInteraction(record);
-            
-            // 更新文章点赞数
-            knowledgeArticleMapper.updateLikeCount(articleId, 1);
-            
-            return result;
-        } else {
-            // 取消点赞操作
-            if (existRecord == null) {
-                // 未点赞,无需操作
-                return 1;
-            }
-            
-            // 删除点赞记录
-            int result = userInteractionMapper.deleteUserInteraction(userId, articleId, "like");
-            
-            // 更新文章点赞数
-            knowledgeArticleMapper.updateLikeCount(articleId, -1);
-            
-            return result;
-        }
-    }
-
-    /**
-     * 用户收藏/取消收藏文章
-     */
-    @Override
-    public int favoriteArticle(Integer articleId, Integer userId, boolean isFavorite) {
-        if (userId == null || articleId == null) {
-            return 0;
-        }
-        
-        // 检查文章是否存在
-        KnowledgeArticle article = knowledgeArticleMapper.selectKnowledgeArticleById(articleId);
-        if (article == null) {
-            return 0;
-        }
-        
-        // 查询是否已收藏
-        UserInteraction existRecord = userInteractionMapper.selectUserInteraction(userId, articleId, "favorite");
-        
-        if (isFavorite) {
-            // 收藏操作
-            if (existRecord != null) {
-                // 已收藏,无需操作
-                return 1;
-            }
-            
-            // 创建收藏记录
-            UserInteraction record = new UserInteraction();
-            record.setUserId(userId);
-            record.setArticleId(articleId);
-            record.setType("favorite");
-            record.setCreateTime(new Date());
-            return userInteractionMapper.insertUserInteraction(record);
-        } else {
-            // 取消收藏操作
-            if (existRecord == null) {
-                // 未收藏,无需操作
-                return 1;
-            }
-            
-            // 删除收藏记录
-            return userInteractionMapper.deleteUserInteraction(userId, articleId, "favorite");
-        }
-    }
-    
-    /**
-     * 根据ID查询知识文章
-     */
-    @Override
-    public KnowledgeArticle selectKnowledgeArticleById(Integer id) {
-        return knowledgeArticleMapper.selectKnowledgeArticleById(id);
-    }
-
-    /**
-     * 将实体对象转换为前端VO对象
-     */
-    private KnowledgeArticleVO convertToVO(KnowledgeArticle article, Integer userId) {
-        if (article == null) {
-            return null;
-        }
-        
-        KnowledgeArticleVO vo = new KnowledgeArticleVO();
-        vo.setId(article.getId());
-        vo.setTitle(article.getTitle());
-        vo.setDescription(article.getDescription());
-        vo.setContent(article.getContent());
-        vo.setType(article.getCategory());
-        vo.setImage(article.getThumbnail());
-        vo.setContentType(article.getContentType());
-        vo.setVideoUrl(article.getVideoUrl());
-        vo.setDuration(article.getVideoDuration());
-        vo.setSource(article.getSource());
-        vo.setPublishTime(article.getPublishDate());
-        vo.setViewCount(article.getViewCount());
-        vo.setLikeCount(article.getLikeCount());
-        
-        // 设置用户是否点赞和收藏
-        if (userId != null) {
-            boolean isLiked = userInteractionMapper.checkUserInteraction(userId, article.getId(), "like");
-            boolean isFavorite = userInteractionMapper.checkUserInteraction(userId, article.getId(), "favorite");
-            vo.setIsLiked(isLiked ? 1 : 0);
-            vo.setIsFavorite(isFavorite ? 1 : 0);
-        } else {
-            vo.setIsLiked(0);
-            vo.setIsFavorite(0);
-        }
-        
-        return vo;
-    }
-    
-    /**
-     * 批量转换为前端VO对象
-     */
-    private List<KnowledgeArticleVO> convertToVOList(List<KnowledgeArticle> articles, Integer userId) {
-        List<KnowledgeArticleVO> voList = new ArrayList<>();
-        
-        if (articles != null && !articles.isEmpty()) {
-            for (KnowledgeArticle article : articles) {
-                voList.add(convertToVO(article, userId));
-            }
-        }
-        
-        return voList;
-    }
-} 

+ 1 - 1
ruoyi-modules/ruoyi-uniapp/src/main/resources/mapper/KnowledgeImageMapper.xml

@@ -23,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectKnowledgeImageById" parameterType="Integer" resultMap="KnowledgeImageResult">
         <include refid="selectKnowledgeImageVo"/>
-        where id = #{id}
+        where article_id = #{id}
     </select>
     
     <select id="selectKnowledgeImageList" parameterType="com.ruoyi.uniapp.domain.KnowledgeImage" resultMap="KnowledgeImageResult">

+ 126 - 0
ruoyi-modules/ruoyi-uniapp/src/main/resources/mapper/uniapp/KnowledgeContentMapper.xml

@@ -0,0 +1,126 @@
+<?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.uniapp.mapper.KnowledgeContentMapper">
+    
+    <resultMap type="com.ruoyi.uniapp.domain.KnowledgeContent" id="KnowledgeContentResult">
+        <id     property="id"              column="id"                />
+        <result property="title"           column="title"             />
+        <result property="description"     column="description"       />
+        <result property="contentType"     column="content_type"      />
+        <result property="contentCategory" column="content_category"  />
+        <result property="imageUrl"        column="image_url"         />
+        <result property="source"          column="source"            />
+        <result property="viewCount"       column="view_count"        />
+        <result property="videoUrl"        column="video_url"         />
+        <result property="duration"        column="duration"          />
+        <result property="articleContent"  column="article_content"   />
+        <result property="author"          column="author"            />
+        <result property="tags"            column="tags"              />
+        <result property="publishDate"     column="publish_date"      />
+        <result property="status"          column="status"            />
+        <result property="createTime"      column="create_time"       />
+        <result property="updateTime"      column="update_time"       />
+        <collection property="knowledgeImage" ofType="com.ruoyi.uniapp.domain.KnowledgeImage" column="id" select="com.ruoyi.uniapp.mapper.KnowledgeImageMapper.selectKnowledgeImageById"/>
+    </resultMap>
+
+    <sql id="selectKnowledgeContentVo">
+        select id, title, description, content_type, content_category, image_url, source, view_count,
+        video_url, duration, article_content, author, tags, publish_date, status, create_time, update_time
+        from knowledge_content
+    </sql>
+
+    <select id="selectKnowledgeContentList" parameterType="com.ruoyi.uniapp.domain.KnowledgeContent" resultMap="KnowledgeContentResult">
+        <include refid="selectKnowledgeContentVo"/>
+        where status = 1
+        <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
+        <if test="contentType != null  and contentType != ''"> and content_type = #{contentType}</if>
+        <if test="contentCategory != null  and contentCategory != ''"> and content_category = #{contentCategory}</if>
+        <if test="source != null  and source != ''"> and source like concat('%', #{source}, '%')</if>
+        <if test="author != null  and author != ''"> and author like concat('%', #{author}, '%')</if>
+        order by publish_date desc
+    </select>
+    
+    <select id="selectKnowledgeContentById" parameterType="Integer" resultMap="KnowledgeContentResult">
+        <include refid="selectKnowledgeContentVo"/>
+        where id = #{id}
+    </select>
+    
+    <insert id="insertKnowledgeContent" parameterType="com.ruoyi.uniapp.domain.KnowledgeContent" useGeneratedKeys="true" keyProperty="id">
+        insert into knowledge_content
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="title != null">title,</if>
+            <if test="description != null">description,</if>
+            <if test="contentType != null">content_type,</if>
+            <if test="contentCategory != null">content_category,</if>
+            <if test="imageUrl != null">image_url,</if>
+            <if test="source != null">source,</if>
+            <if test="viewCount != null">view_count,</if>
+            <if test="videoUrl != null">video_url,</if>
+            <if test="duration != null">duration,</if>
+            <if test="articleContent != null">article_content,</if>
+            <if test="author != null">author,</if>
+            <if test="tags != null">tags,</if>
+            <if test="publishDate != null">publish_date,</if>
+            <if test="status != null">status,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="title != null">#{title},</if>
+            <if test="description != null">#{description},</if>
+            <if test="contentType != null">#{contentType},</if>
+            <if test="contentCategory != null">#{contentCategory},</if>
+            <if test="imageUrl != null">#{imageUrl},</if>
+            <if test="source != null">#{source},</if>
+            <if test="viewCount != null">#{viewCount},</if>
+            <if test="videoUrl != null">#{videoUrl},</if>
+            <if test="duration != null">#{duration},</if>
+            <if test="articleContent != null">#{articleContent},</if>
+            <if test="author != null">#{author},</if>
+            <if test="tags != null">#{tags},</if>
+            <if test="publishDate != null">#{publishDate},</if>
+            <if test="status != null">#{status},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+        </trim>
+    </insert>
+
+    <update id="updateKnowledgeContent" parameterType="com.ruoyi.uniapp.domain.KnowledgeContent">
+        update knowledge_content
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="title != null">title = #{title},</if>
+            <if test="description != null">description = #{description},</if>
+            <if test="contentType != null">content_type = #{contentType},</if>
+            <if test="contentCategory != null">content_category = #{contentCategory},</if>
+            <if test="imageUrl != null">image_url = #{imageUrl},</if>
+            <if test="source != null">source = #{source},</if>
+            <if test="viewCount != null">view_count = #{viewCount},</if>
+            <if test="videoUrl != null">video_url = #{videoUrl},</if>
+            <if test="duration != null">duration = #{duration},</if>
+            <if test="articleContent != null">article_content = #{articleContent},</if>
+            <if test="author != null">author = #{author},</if>
+            <if test="tags != null">tags = #{tags},</if>
+            <if test="publishDate != null">publish_date = #{publishDate},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteKnowledgeContentById" parameterType="Integer">
+        delete from knowledge_content where id = #{id}
+    </delete>
+
+    <delete id="deleteKnowledgeContentByIds" parameterType="String">
+        delete from knowledge_content where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+    
+    <update id="incrementViewCount" parameterType="Integer">
+        update knowledge_content set view_count = view_count + 1 where id = #{id}
+    </update>
+</mapper>