Selaa lähdekoodia

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

张延森 3 vuotta sitten
vanhempi
commit
4c068670c5

+ 12
- 6
src/main/java/com/yunzhi/shigongli/controller/TaExtendContentController.java Näytä tiedosto

4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.yunzhi.shigongli.common.BaseController;
6
 import com.yunzhi.shigongli.common.BaseController;
7
+import com.yunzhi.shigongli.common.Constants;
7
 import com.yunzhi.shigongli.common.ResponseBean;
8
 import com.yunzhi.shigongli.common.ResponseBean;
8
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiOperation;
53
     public ResponseBean taExtendContentList(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
54
     public ResponseBean taExtendContentList(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
54
                                             @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55
                                             @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55
                                             @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
56
                                             @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
57
+                                            @ApiParam("内容类型") @RequestParam(value ="contentType") String contentType,
56
                                             HttpServletRequest request) throws Exception{
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
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
75
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
73
     public ResponseBean taExtendContentAdd(@ApiParam("保存内容") @RequestBody TaExtendContent taExtendContent) throws Exception{
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
         if (iTaExtendContentService.save(taExtendContent)){
81
         if (iTaExtendContentService.save(taExtendContent)){
76
             return ResponseBean.success(taExtendContent);
82
             return ResponseBean.success(taExtendContent);
77
         }else {
83
         }else {
86
     @RequestMapping(value="/admin/taExtendContent/{id}", method= RequestMethod.DELETE)
92
     @RequestMapping(value="/admin/taExtendContent/{id}", method= RequestMethod.DELETE)
87
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
93
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
88
     public ResponseBean taExtendContentDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
94
     public ResponseBean taExtendContentDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
89
-        if(iTaExtendContentService.removeLogicById(id)){
95
+        if(iTaExtendContentService.removeById(id)){
90
             return ResponseBean.success("success");
96
             return ResponseBean.success("success");
91
         }else {
97
         }else {
92
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
98
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);

+ 13
- 6
src/main/java/com/yunzhi/shigongli/controller/TdTypeController.java Näytä tiedosto

4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.yunzhi.shigongli.common.BaseController;
6
 import com.yunzhi.shigongli.common.BaseController;
7
+import com.yunzhi.shigongli.common.Constants;
7
 import com.yunzhi.shigongli.common.ResponseBean;
8
 import com.yunzhi.shigongli.common.ResponseBean;
9
+import com.yunzhi.shigongli.common.StringUtils;
8
 import io.swagger.annotations.Api;
10
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
11
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
12
 import io.swagger.annotations.ApiParam;
50
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
52
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
     public ResponseBean tdTypeList(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
53
     public ResponseBean tdTypeList(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
52
                                    @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
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 Näytä tiedosto

13
  */
13
  */
14
 public interface ITaExtendContentService extends IBaseService<TaExtendContent> {
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 Näytä tiedosto

1
 package com.yunzhi.shigongli.service.impl;
1
 package com.yunzhi.shigongli.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
3
 import com.yunzhi.shigongli.entity.TaExtendContent;
4
 import com.yunzhi.shigongli.entity.TaExtendContent;
4
 import com.yunzhi.shigongli.mapper.TaExtendContentMapper;
5
 import com.yunzhi.shigongli.mapper.TaExtendContentMapper;
5
 import com.yunzhi.shigongli.service.ITaExtendContentService;
6
 import com.yunzhi.shigongli.service.ITaExtendContentService;
17
 @Service
18
 @Service
18
 public class TaExtendContentServiceImpl extends BaseServiceImpl<TaExtendContentMapper, TaExtendContent> implements ITaExtendContentService {
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
 }