浏览代码

案例列表查询

lyhzzz 2 年之前
父节点
当前提交
a44f1d0370
共有 1 个文件被更改,包括 13 次插入2 次删除
  1. 13 2
      src/main/java/com/fdkankan/ucenter/controller/ArticleController.java

+ 13 - 2
src/main/java/com/fdkankan/ucenter/controller/ArticleController.java

@@ -2,11 +2,13 @@ package com.fdkankan.ucenter.controller;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.ucenter.common.BaseController;
 import com.fdkankan.ucenter.common.Result;
 import com.fdkankan.ucenter.entity.Article;
 import com.fdkankan.ucenter.entity.Case;
 import com.fdkankan.ucenter.service.IArticleService;
 import com.fdkankan.ucenter.service.ICaseService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
@@ -23,7 +25,7 @@ import javax.annotation.PostConstruct;
  */
 @RestController
 @RequestMapping("/ucenter/article")
-public class ArticleController {
+public class ArticleController extends BaseController {
 
     @Autowired
     ICaseService caseService;
@@ -39,10 +41,19 @@ public class ArticleController {
     }
 
     @PostMapping("/allList")
-    public Result allList() throws Exception {
+    public Result allList(@RequestBody Case caseEntity) throws Exception {
+        String lang = getLang();
+        if("zh".equals(lang)){
+            lang = "cn";
+        }
         LambdaQueryWrapper<Case> wrapper = new LambdaQueryWrapper<>();
+        if(StringUtils.isNotBlank(caseEntity.getTypeId())){
+            wrapper.eq(Case::getTypeId,caseEntity.getTypeId());
+        }
+        wrapper.eq(Case::getLanguage,lang);
         wrapper.eq(Case::getIsPublic,1);
         wrapper.orderByAsc(Case::getSort);
+        wrapper.orderByAsc(Case::getId);
         return Result.success(caseService.list(wrapper));
     }