Commit 8eabff35ac0035febd656926cf669450e932c1a9

Authored by changpengfei
1 parent 99699c3685
Exists in master

update

Showing 1 changed file with 12 additions and 2 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ArticleController.java View file @ 8eabff3
1 1 package com.lyms.talkonlineweb.controller;
2 2  
  3 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4 5 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 6 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
... ... @@ -14,6 +15,7 @@
14 15 import org.springframework.beans.factory.annotation.Autowired;
15 16 import org.springframework.beans.factory.annotation.Value;
16 17 import org.springframework.http.codec.multipart.Part;
  18 +import org.springframework.util.StringUtils;
17 19 import org.springframework.web.bind.annotation.*;
18 20 import org.springframework.web.multipart.MultipartFile;
19 21  
20 22  
21 23  
22 24  
... ... @@ -101,12 +103,20 @@
101 103 BaseResponse baseResponse = new BaseResponse();
102 104 Page<ArticleInfo> page = new Page<>(current, size);
103 105 Page<ArticleInfo> articlePagePage = new Page<>();
  106 + QueryWrapper query=new QueryWrapper();
  107 + if(StringUtils.isEmpty(article.getTitle())){
  108 + article.setTitle(null);
  109 + }else{
  110 + query.like("title",article.getTitle());
  111 + }
  112 +
104 113 if (sort == 1) {
105   - articlePagePage = articleInfoService.page(page, Wrappers.query(article).orderByDesc("updated_time", "createdtime"));
  114 + query.orderByDesc("updated_time", "createdtime");
106 115 }
107 116 if (sort == 2) {
108   - articlePagePage = articleInfoService.page(page, Wrappers.query(article).orderByAsc("updated_time", "createdtime"));
  117 + query.orderByAsc("updated_time", "createdtime");
109 118 }
  119 + articlePagePage = articleInfoService.page(page, query);
110 120 baseResponse.setObject(articlePagePage);
111 121  
112 122 return baseResponse;