Browse Source

Merge branch 'dev' of http://git.ycjcjy.com/shigongli/service-v2 into dev

张延森 3 years ago
parent
commit
4c068670c5

+ 12
- 6
src/main/java/com/yunzhi/shigongli/controller/TaExtendContentController.java View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.shigongli.common.BaseController;
7
+import com.yunzhi.shigongli.common.Constants;
7 8
 import com.yunzhi.shigongli.common.ResponseBean;
8 9
 import io.swagger.annotations.Api;
9 10
 import io.swagger.annotations.ApiOperation;
@@ -53,14 +54,16 @@ public class TaExtendContentController extends BaseController {
53 54
     public ResponseBean taExtendContentList(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
54 55
                                             @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55 56
                                             @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
57
+                                            @ApiParam("内容类型") @RequestParam(value ="contentType") String contentType,
56 58
                                             HttpServletRequest request) throws Exception{
57 59
 
58
-		    IPage<TaExtendContent> pg = new Page<>(pageNum, pageSize);
59
-            QueryWrapper<TaExtendContent> queryWrapper = new QueryWrapper<>();
60
-            queryWrapper.orderByDesc("create_date");
60
+        IPage<TaExtendContent> pg = new Page<>(pageNum, pageSize);
61
+        QueryWrapper<TaExtendContent> queryWrapper = new QueryWrapper<>();
62
+        queryWrapper.eq("content_type", contentType);
63
+        queryWrapper.orderByAsc("sort");
61 64
 
62
-            IPage<TaExtendContent> result = iTaExtendContentService.page(pg, queryWrapper);
63
-            return ResponseBean.success(result);
65
+        IPage<TaExtendContent> result = iTaExtendContentService.page(pg, queryWrapper);
66
+        return ResponseBean.success(result);
64 67
     }
65 68
 
66 69
     /**
@@ -72,6 +75,9 @@ public class TaExtendContentController extends BaseController {
72 75
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
73 76
     public ResponseBean taExtendContentAdd(@ApiParam("保存内容") @RequestBody TaExtendContent taExtendContent) throws Exception{
74 77
 
78
+        int max = iTaExtendContentService.getMaxSort(taExtendContent.getContentType());
79
+        taExtendContent.setSort(max + 1);
80
+
75 81
         if (iTaExtendContentService.save(taExtendContent)){
76 82
             return ResponseBean.success(taExtendContent);
77 83
         }else {
@@ -86,7 +92,7 @@ public class TaExtendContentController extends BaseController {
86 92
     @RequestMapping(value="/admin/taExtendContent/{id}", method= RequestMethod.DELETE)
87 93
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
88 94
     public ResponseBean taExtendContentDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
89
-        if(iTaExtendContentService.removeLogicById(id)){
95
+        if(iTaExtendContentService.removeById(id)){
90 96
             return ResponseBean.success("success");
91 97
         }else {
92 98
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);

+ 13
- 6
src/main/java/com/yunzhi/shigongli/controller/TdTypeController.java View File

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.shigongli.common.BaseController;
7
+import com.yunzhi.shigongli.common.Constants;
7 8
 import com.yunzhi.shigongli.common.ResponseBean;
9
+import com.yunzhi.shigongli.common.StringUtils;
8 10
 import io.swagger.annotations.Api;
9 11
 import io.swagger.annotations.ApiOperation;
10 12
 import io.swagger.annotations.ApiParam;
@@ -50,14 +52,19 @@ public class TdTypeController extends BaseController {
50 52
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51 53
     public ResponseBean tdTypeList(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
52 54
                                    @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
53
-                                   @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
55
+                                   @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
56
+                                   @ApiParam("分类名称") @RequestParam(value ="typeName", required = false) String typeName) throws Exception{
54 57
 
55
-		    IPage<TdType> pg = new Page<>(pageNum, pageSize);
56
-            QueryWrapper<TdType> queryWrapper = new QueryWrapper<>();
57
-            queryWrapper.orderByDesc("create_date");
58
+        IPage<TdType> pg = new Page<>(pageNum, pageSize);
59
+        QueryWrapper<TdType> queryWrapper = new QueryWrapper<>();
60
+        queryWrapper.like(StringUtils.isEmpty(typeName), "type_name", "%"+typeName+"%");
61
+        queryWrapper.eq("wx".equals(plat), "status", Constants.STATUS_NORMAL);
62
+        queryWrapper.gt("admin".equals(plat), "status", Constants.STATUS_DELETED);
63
+        queryWrapper.orderByDesc("weight");
64
+        queryWrapper.orderByDesc("create_date");
58 65
 
59
-            IPage<TdType> result = iTdTypeService.page(pg, queryWrapper);
60
-            return ResponseBean.success(result);
66
+        IPage<TdType> result = iTdTypeService.page(pg, queryWrapper);
67
+        return ResponseBean.success(result);
61 68
     }
62 69
 
63 70
     /**

+ 1
- 0
src/main/java/com/yunzhi/shigongli/service/ITaExtendContentService.java View File

@@ -13,4 +13,5 @@ import com.yunzhi.shigongli.entity.TaExtendContent;
13 13
  */
14 14
 public interface ITaExtendContentService extends IBaseService<TaExtendContent> {
15 15
 
16
+    int getMaxSort(String contentType);
16 17
 }

+ 12
- 0
src/main/java/com/yunzhi/shigongli/service/impl/TaExtendContentServiceImpl.java View File

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
3 4
 import com.yunzhi.shigongli.entity.TaExtendContent;
4 5
 import com.yunzhi.shigongli.mapper.TaExtendContentMapper;
5 6
 import com.yunzhi.shigongli.service.ITaExtendContentService;
@@ -17,4 +18,15 @@ import org.springframework.stereotype.Service;
17 18
 @Service
18 19
 public class TaExtendContentServiceImpl extends BaseServiceImpl<TaExtendContentMapper, TaExtendContent> implements ITaExtendContentService {
19 20
 
21
+    @Override
22
+    public int getMaxSort(String contentType) {
23
+        LambdaQueryWrapper<TaExtendContent> queryWrapper = new LambdaQueryWrapper<>();
24
+        queryWrapper.eq(TaExtendContent::getContentType, contentType);
25
+        queryWrapper.orderByDesc(TaExtendContent::getSort);
26
+        queryWrapper.last("limit 1");
27
+
28
+        TaExtendContent extendContent = getOne(queryWrapper);
29
+
30
+        return null == extendContent ? 0 : extendContent.getSort();
31
+    }
20 32
 }