fzzj před 8 měsíci
rodič
revize
1a52e68c07

+ 1
- 1
RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/novel/controller/NovelController.java Zobrazit soubor

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

+ 10
- 0
RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/novel/domain/Novel.java Zobrazit soubor

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

+ 1
- 0
RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/novel/mapper/NovelMapper.java Zobrazit soubor

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

+ 1
- 0
RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/novel/service/NovelService.java Zobrazit soubor

19
 @Service
19
 @Service
20
 @Transactional
20
 @Transactional
21
 public interface NovelService {
21
 public interface NovelService {
22
+    List<Novel> selectNovelOneList(Novel novel);
22
     List<Novel> selectNovelList(Novel novel);
23
     List<Novel> selectNovelList(Novel novel);
23
 
24
 
24
     @Transactional
25
     @Transactional

+ 4
- 0
RuoYi-Vue/ruoyi-system/src/main/java/com/ruoyi/novel/service/impl/NovelServiceImpl.java Zobrazit soubor

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

+ 31
- 3
RuoYi-Vue/ruoyi-system/src/main/resources/mapper/novel/NovelMapper.xml Zobrazit soubor

12
         <result property="description"  column="description"   />
12
         <result property="description"  column="description"   />
13
         <result property="status"       column="status"        />
13
         <result property="status"       column="status"        />
14
         <result property="wordCount"    column="word_count"    />
14
         <result property="wordCount"    column="word_count"    />
15
-        <result property="readCount"    column="word_count"    />
15
+        <result property="readCount"    column="read_count"    />
16
         <result property="createTime"   column="create_time"   />
16
         <result property="createTime"   column="create_time"   />
17
         <result property="updateTime"   column="update_time"   />
17
         <result property="updateTime"   column="update_time"   />
18
+        <result property="authorId"   column="author_id"   />
19
+        <result property="cover"   column="cover"   />
18
     </resultMap>
20
     </resultMap>
19
 
21
 
20
     <!-- 基础字段列表 -->
22
     <!-- 基础字段列表 -->
21
     <sql id="selectNovelVo">
23
     <sql id="selectNovelVo">
22
         select
24
         select
23
             id, title, author, category_id, cover_img, description,
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
         from novel
27
         from novel
26
     </sql>
28
     </sql>
27
     <select id="selectList" resultMap="NovelResult">
29
     <select id="selectList" resultMap="NovelResult">
28
         SELECT * FROM novel
30
         SELECT * FROM novel
29
     </select>
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
     <select id="selectNovelList" parameterType="Novel" resultMap="NovelResult">
57
     <select id="selectNovelList" parameterType="Novel" resultMap="NovelResult">
32
         <include refid="selectNovelVo"/>
58
         <include refid="selectNovelVo"/>
44
                 <!-- 全文索引模式 -->
70
                 <!-- 全文索引模式 -->
45
                 AND MATCH(title, author, description) AGAINST (#{keyword} IN BOOLEAN MODE)
71
                 AND MATCH(title, author, description) AGAINST (#{keyword} IN BOOLEAN MODE)
46
             </if>
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
             <if test="description != null and description != ''"> AND description LIKE CONCAT('%', #{description}, '%')</if>
76
             <if test="description != null and description != ''"> AND description LIKE CONCAT('%', #{description}, '%')</if>
49
 
77
 
50
             <if test="status != null and status != ''"> AND status = #{status}</if>
78
             <if test="status != null and status != ''"> AND status = #{status}</if>

Načítá se…
Zrušit
Uložit