fzzj пре 8 месеци
родитељ
комит
1a52e68c07

+ 1
- 1
RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/novel/controller/NovelController.java Прегледај датотеку

@@ -80,7 +80,7 @@ public class NovelController extends BaseController {
80 80
     @GetMapping("/list")
81 81
     public TableDataInfo list(Novel novel) {
82 82
         startPage();
83
-        List<Novel> list = novelService.selectNovelList(novel);
83
+        List<Novel> list = novelService.selectNovelOneList(novel);
84 84
         // 关联分类名称
85 85
         list.forEach(n -> {
86 86
             NovelCategory category = (NovelCategory) novelService.getNovelsByCategory(n.getCategoryId());

+ 10
- 0
RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/novel/domain/Novel.java Прегледај датотеку

@@ -28,16 +28,26 @@ public class Novel {
28 28
     @TableId(type = IdType.AUTO)
29 29
     private Long id;
30 30
     //@Field(type = FieldType.Text, analyzer = "ik_max_word")
31
+    @TableField("title")
31 32
     private String title;
32 33
     //@Field(type = FieldType.Keyword)
34
+    @TableField(exist = false)
35
+    private String keyword;
36
+//    @TableField(exist = false)
37
+//    private String authorName;
38
+
39
+    @TableField("author")
33 40
     private String author;
34 41
     @TableField("cover_img")
35 42
     private String coverImg;
36 43
     @TableField("category_id")
37 44
     private Long categoryId;
38 45
     //@Field(type = FieldType.Keyword)
46
+    @TableField("status")
39 47
     private Integer status = 0; // 0: 连载中, 1: 已完结// 连载/完本
40 48
     //@Field(type = FieldType.Text, analyzer = "ik_smart")
49
+    // 添加其他在 XML 中使用的字段
50
+    @TableField(exist = false)
41 51
     private String description;
42 52
     @TableField("word_count")
43 53
     private Long wordCount;

+ 1
- 0
RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/novel/mapper/NovelMapper.java Прегледај датотеку

@@ -13,6 +13,7 @@ import java.util.Map;
13 13
 // NovelMapper.java
14 14
 public interface NovelMapper extends BaseMapper<Novel> {
15 15
     List<Novel> selectNovelList(@Param("novel") Novel novel,@Param("keyword") String keyword);
16
+    List<Novel> selectNovelOneList(@Param("novel") Novel novel);
16 17
     Novel selectNovelById(Long id);
17 18
     int insertNovel(Novel novel);
18 19
     int updateNovel(Novel novel);

+ 1
- 0
RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/novel/service/NovelService.java Прегледај датотеку

@@ -19,6 +19,7 @@ import java.util.List;
19 19
 @Service
20 20
 @Transactional
21 21
 public interface NovelService {
22
+    List<Novel> selectNovelOneList(Novel novel);
22 23
     List<Novel> selectNovelList(Novel novel);
23 24
 
24 25
     @Transactional

+ 4
- 0
RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/novel/service/impl/NovelServiceImpl.java Прегледај датотеку

@@ -340,6 +340,10 @@ public class NovelServiceImpl implements NovelService {
340 340
         return rspData;
341 341
     }
342 342
     @Override
343
+    public List<Novel> selectNovelOneList(Novel novel) {
344
+        return novelMapper.selectNovelOneList(novel);
345
+    }
346
+    @Override
343 347
     public List<Novel> selectNovelList(Novel novel) {
344 348
         return novelMapper.selectNovelList(novel,null);
345 349
     }

+ 31
- 3
RuoYi-Vue/ruoyi-system/src/main/resources/mapper/novel/NovelMapper.xml Прегледај датотеку

@@ -12,21 +12,47 @@
12 12
         <result property="description"  column="description"   />
13 13
         <result property="status"       column="status"        />
14 14
         <result property="wordCount"    column="word_count"    />
15
-        <result property="readCount"    column="word_count"    />
15
+        <result property="readCount"    column="read_count"    />
16 16
         <result property="createTime"   column="create_time"   />
17 17
         <result property="updateTime"   column="update_time"   />
18
+        <result property="authorId"   column="author_id"   />
19
+        <result property="cover"   column="cover"   />
18 20
     </resultMap>
19 21
 
20 22
     <!-- 基础字段列表 -->
21 23
     <sql id="selectNovelVo">
22 24
         select
23 25
             id, title, author, category_id, cover_img, description,
24
-            status, word_count, readCount,create_time, update_time
26
+            status, word_count, read_count,create_time, update_time,author_id,cover
25 27
         from novel
26 28
     </sql>
27 29
     <select id="selectList" resultMap="NovelResult">
28 30
         SELECT * FROM novel
29 31
     </select>
32
+    <select id="selectNovelOneList" resultMap="NovelResult">
33
+        <include refid="selectNovelVo"/>
34
+        <where>
35
+            <if test="novel.title != null and novel.title != ''">
36
+                AND title LIKE CONCAT('%', #{novel.title}, '%')
37
+            </if>
38
+            <if test="novel.categoryId != null">
39
+                AND category_id = #{novel.categoryId}
40
+            </if>
41
+            <if test="novel.keyword != null and novel.keyword != ''">
42
+                AND MATCH(title, author, description) AGAINST (#{novel.keyword} IN BOOLEAN MODE)
43
+            </if>
44
+            <if test="novel.author != null and novel.author != ''">
45
+                AND author LIKE CONCAT('%', #{novel.author}, '%')
46
+            </if>
47
+            <if test="novel.description != null and novel.description != ''">
48
+                AND description LIKE CONCAT('%', #{novel.description}, '%')
49
+            </if>
50
+            <if test="novel.status != null">
51
+                AND status = #{novel.status}
52
+            </if>
53
+        </where>
54
+        ORDER BY update_time DESC
55
+    </select>
30 56
 
31 57
     <select id="selectNovelList" parameterType="Novel" resultMap="NovelResult">
32 58
         <include refid="selectNovelVo"/>
@@ -44,7 +70,9 @@
44 70
                 <!-- 全文索引模式 -->
45 71
                 AND MATCH(title, author, description) AGAINST (#{keyword} IN BOOLEAN MODE)
46 72
             </if>
47
-            <if test="authorName != null and authorName != ''"> AND author_name LIKE CONCAT('%', #{authorName}, '%')</if>
73
+            <if test="novel.author != null and novel.author != ''">
74
+                AND author LIKE CONCAT('%', #{novel.author}, '%')
75
+            </if>
48 76
             <if test="description != null and description != ''"> AND description LIKE CONCAT('%', #{description}, '%')</if>
49 77
 
50 78
             <if test="status != null and status != ''"> AND status = #{status}</if>

Loading…
Откажи
Сачувај